Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

2d Scroller Question

  Asked By: Ted    Date: Dec 24    Category: Java    Views: 675
  

I've been trying to make a 2-D scroller (like super mario) and maybe
because my brain is limited or something I can't seem to figure out
a problem that might be pretty trivial.

Here's the question. Let's say you're not pressing the right or
left arrow key to make the character move left or right. So,
there's a time when the character is just standing there. I have
all the neccessary frame work already, but the problem is in code, I
don't have any idea how I can tell if he's either facing left or
right when he's not doing anything.

So what kind of if statement can I use to see if he's facing left or
right? Keep in mind I can access the character's velocity and
location, in the x and y coordinates. Also, the time that passed.

Sample Code:
if (getVx() < 0) {
newAnimation = left;
}

This says that if the velocity in the x direction is less than
zero, meaning he's moving left, then he'll be animated moving left.

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on 2d Scroller Question Or get search suggestion and latest updates.




Tagged: