Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / changing direction of sprite animation

Author
Message
Ched80
13
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 1st May 2013 11:37
Hi,
Is there anyway to set the direction in which an animation plays?

I have a walking animation set as a grid of images, but if I want to walk backwards I have to create a second image grid and swap it each sync call. It would be much quicker if we could just switch the direction in which the animation plays. I couldn't see how to do this from the help file.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st May 2013 13:06
You can manually set the frame using "setSpriteFrame". That's how I do it anyway. I don't tend to use playSprite...


this.mess = abs(sin(times#))
Ched80
13
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 1st May 2013 13:12
Cheers, so if I set the reverse order of frames, say frame 7 to frame 1, the animation runs backwards?

haliop
User Banned
Posted: 1st May 2013 13:24
yep just remmeber to put a timer in between cause if not it will be more faster then the eye can see.. there are some timers for 2d animations here in the forum.. you can check AGK/ DBP/ DGDK ive seen a few , search.

Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 1st May 2013 13:40
Ched80, you are asking how to change the direction so that the animation faces the other way, right? If so, SetSpriteFlip is what you are after...

Playing the animation in reverse would make your character look as if he is doing a moon walk
Ched80
13
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 1st May 2013 14:04
Cheers,

Why do I need a timer when I can set the animation speed?

Thanks for the tip Funnell7, but my game is a top down shooter, not a platformer.

Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 1st May 2013 14:29
Quote: "but my game is a top down shooter, not a platformer"


Good point, I made a massive assumption there...

You'd only need a timer if you opted against using PlaySprite (as suggested by Bax).
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st May 2013 14:32 Edited at: 1st May 2013 14:33
Yes, for example you would need to do a check each loop like this:



this.mess = abs(sin(times#))
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 1st May 2013 15:49
//PlaySprite( spr, 30, 1, 1, 13 ) play frame 1-13
//PlaySprite( spr, 30, 1, 13, 1 ) play frame 13-1
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st May 2013 17:38
I am willing to bet that you cannot specify a start frame greater than the end frame for PlaySprite and have it work.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 1st May 2013 17:56 Edited at: 1st May 2013 17:56
@Ancient Lady
it works

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st May 2013 18:06
Awesome! That means I don't have to do the extra things in my animations. I like it!

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Ched80
13
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 1st May 2013 18:18
Fantastic! Cheers everyone, this saves me a shed load of extra images

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st May 2013 18:18
That's handy to know I just assumed it would not work that way around. Never assume.


this.mess = abs(sin(times#))
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd May 2013 22:01
Why would you not want to use playSprite?

"You're all wrong. You're all idiots." ~Fluffy Rabbit
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 3rd May 2013 04:19
I tried using playSprite() in dFenz for the ship rolling.
You may/may not notice that when you stop pressing on the screen the ship returns to 0 degrees roll. I tried to get playSprite() to work for that, but it wouldn't. For some reason it kept getting locked into a frame when you tried to move the opposite direction. I searched and searched for a logic error, but couldn't find it and in the end I had to manually set the frames. Manually setting the frames actually turned out to be much easier. I think what was happening is playSprite() was being called too often, but I never ran tests to be sure.

So I can imagine if you have a sprite who's frames change based on anything other than the timer (position, collision, user input, etc) it might be easier to manually step through the frames.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd May 2013 21:37
It was a little bit of a headache in my zelda game. Sorting out when to call playsprite, when to stop, when to resume instead of play, when to set the frame when switching animations.... I eventually got it working but I was used to DB where you had to call playsprite every loop.

"You're all wrong. You're all idiots." ~Fluffy Rabbit

Login to post a reply

Server time is: 2024-05-03 20:18:02
Your offset time is: 2024-05-03 20:18:02