animation+accelerometer

Game Editor comments and discussion.

animation+accelerometer

Postby Fojam » Tue Sep 20, 2011 11:27 pm

ok i have the accelerometer function working so i can tilt to move my character left and right. the only problem is that i can't get him to animate while he is running in a certain direction. my code for the man moving is

Code: Select all
Vector v = getAccelerometer();
    xvelocity = v.y * -70;


can anyone help?
CLICK TO GIVE ME POINTS

My Latest Projects:
Super Smash Bros: viewtopic.php?f=6&t=12307 PLEASE help by making sprites!
User avatar
Fojam
 
Posts: 513
Joined: Thu Mar 19, 2009 10:02 pm
Location: under your bed!!!
Score: 69 Give a positive score

Re: animation+accelerometer

Postby skydereign » Wed Sep 21, 2011 1:09 am

Oh, that is the problem you were having? You should have mentioned you were having problems with animations. Anyway, if the animations are in a certain order, than you can use that to your advantage, and avoid an if. Otherwise, you'll probably have to use an if.
Code: Select all
if(xvelocity>0)
{
    // ChangeAnimation to run right NO_CHANGE
}
else
{
    // ChangeAnimation to run left NO_CHANGE
}


Also it depends on if the actor can use other animations, for example jump. If so then the above won't work with the jumping, but hopefully that is enough to get you going.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: animation+accelerometer

Postby Fojam » Wed Sep 21, 2011 1:14 am

Thanks. Actually i figured out my original problem but i was stumped on this. Thanks for answering
CLICK TO GIVE ME POINTS

My Latest Projects:
Super Smash Bros: viewtopic.php?f=6&t=12307 PLEASE help by making sprites!
User avatar
Fojam
 
Posts: 513
Joined: Thu Mar 19, 2009 10:02 pm
Location: under your bed!!!
Score: 69 Give a positive score

Re: animation+accelerometer

Postby Game A Gogo » Wed Sep 21, 2011 1:05 pm

skydereign wrote:Oh, that is the problem you were having? You should have mentioned you were having problems with animations. Anyway, if the animations are in a certain order, than you can use that to your advantage, and avoid an if. Otherwise, you'll probably have to use an if.
Code: Select all
if(xvelocity>0)
{
    // ChangeAnimation to run right NO_CHANGE
}
else
{
    // ChangeAnimation to run left NO_CHANGE
}


Also it depends on if the actor can use other animations, for example jump. If so then the above won't work with the jumping, but hopefully that is enough to get you going.


what happens if the player is not moving? he'll keep running towards the left...

Code: Select all
if(xvelocity>0)
{
    // ChangeAnimation to run right NO_CHANGE
}
else if(xvelocity<0)
{
    // ChangeAnimation to run left NO_CHANGE
}
else
{
    //ChangeAnimation to standing still NO_CHANGE
}
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: animation+accelerometer

Postby skydereign » Wed Sep 21, 2011 10:21 pm

Hmm, I guess. I assumed it was still just a running game, a lot of them that use tilt don't have a standing position, the tilt is just to change direction. But even then the approach to do it would have been pretty obvious, at least that was my intent. Recently, I've been trying to not do all the thinking for people I help, just enough to get them going.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest