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 / Sprite anim flip/flop

Author
Message
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 12th Apr 2016 01:44
Hmm. Disappointed as I thought this was something that was going to be added?

I still have to write and manage sprite animations that flip/flop animate rather than just set an attribute on playsprite.
I do recall that this was going to be added at some point?

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th Apr 2016 13:16 Edited at: 12th Apr 2016 13:18
What do you mean by flip flop?
Using AppGameKit V2 Tier 1
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 12th Apr 2016 16:13
Play forward until it reaches the end, then play backwards until it reaches the start. Then repeat.
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 12th Apr 2016 16:35
Yes, would love this feature and the ability to play the animation backwards....
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 13th Apr 2016 08:45
Quote: "and the ability to play the animation backwards"

That bit is perfectly do-able now.

PlaySprite( iSpriteIndex, fFps, iLoop, iFromFrame, iToFrame )
Just set the iFromFrame parameter as the last frame and the iToFrame parameter as the first frame.
AGK V2 user - Tier 1 (mostly)
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 13th Apr 2016 09:33 Edited at: 13th Apr 2016 09:50
Had a go at making a function for this simply because I wanted to see what was possible with the current commands and it wasn't particularly easy. I could have just created each frame as a new image but in order to make it run faster at runtime I auto-created a subimage text file so that the frames could be loaded as sub images. That way you can use a single image and still use PlaySprite as usual. This won't work if you have a subimages text file for the image already in the media folder.


EDIT: Scraggles method is fine but requires some additional management to set the animation in reverse once it has run one way and to then reverse it. It might be just as easy to create a small management function that looks after flip-flop animations. Also rather than create the subimages text file every time I would probably check if the file exists first... I'll add a check in for this now.

EDIT2: Separated out the loading / subimage file creation. Much neater and quicker now.
Using AppGameKit V2 Tier 1
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 13th Apr 2016 10:01 Edited at: 13th Apr 2016 10:37
I knocked up a test of this too.
It's not as efficient is baxslash's because you have to call the function each loop but it is less code and doesn't require a subimage text file.


[Edit] It would, of course, be a much neater solution if we could set the iLoop parameter to 2 in order to ping-pong (flip-flop) the animation.
AGK V2 user - Tier 1 (mostly)
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 14th Apr 2016 19:05
I asked for this years ago but there was very little interest back then. Would be very useful.
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 15th Apr 2016 11:32
Quote: "Just set the iFromFrame parameter as the last frame and the iToFrame parameter as the first frame."


Cheers Scraggle - didn't realise you could do this!

OK, back to flip flop....definitely would be good to have that built in
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)

Login to post a reply

Server time is: 2024-09-29 13:21:43
Your offset time is: 2024-09-29 13:21:43