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.

Newcomers AppGameKit Corner / Sprite Animation won't animate in main loop

Author
Message
Artformer
14
Years of Service
User Offline
Joined: 23rd Aug 2010
Location: Scotland
Posted: 13th Jul 2016 18:00
Hello,
Excuse me bothering you with this, but I seem to be missing something in my code.. I'm rebuilding a game I made in DBPro in AGK2, and I'm learning the basics of animation. I've created an atlas image of 8 rows of 5 animation images, which is two separate movements of one character, each being 5 * 4 images = 20 frames each. I can't seem to get any animation whatsoever within the main loop.. I've included the files.. can anyone see what I've done wrong please? This is my own artwork, each frame is 100 * 100
Thanks for your help.
Regards
Howard

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 14th Jul 2016 00:25 Edited at: 14th Jul 2016 00:26
It seems to work ok for me. Nice animation, lots of character
Artformer
14
Years of Service
User Offline
Joined: 23rd Aug 2010
Location: Scotland
Posted: 14th Jul 2016 00:44
The spritesheet has an upward and a downward moving character, and I'd like to have full control of each movement. At the moment, its just playing through 20 frames of each in a continuous loop of 40 frames.
I cannot get PlaySprite to work within the main loop either. I have modified the coding here, but still can't get it to work....

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 14th Jul 2016 01:16 Edited at: 14th Jul 2016 01:37
try this;
Artformer
14
Years of Service
User Offline
Joined: 23rd Aug 2010
Location: Scotland
Posted: 14th Jul 2016 10:27
Good job BlinkOk! Apart from sprites image reversed for up/down key.. (just reversed the key assignment.. probably my error). So now I'm trying to understand what you've done here. curfrm# is a real number not Integer, which I guess is so it will track fractions of a frame, which is rounded up/down by the TRUNC function. But you are not using PLAYSPRITE, so what prints the sprite frames? Is there a limitation in the use of PLAYSPRITE that needs to be fixed, forcing people to ignore it? The animation is running way too fast, so I assume a timer has to be implemented? How can I create the same game speed on multiple platforms? Thanks for the help!
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 14th Jul 2016 12:13
curfrm# is a float so you can control the speed of the animation (Change .05 to say .02 and it will slow down)
SetSpriteFrame() is what displays the frame of the animation
if you want a consistent frame rate you could use elapsed time to select the frame

before you were executing playsprite() every frame so it was always setting the animation to the first frame. you need a system where by playsprite is executed ONLY when the state changes
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 14th Jul 2016 13:49 Edited at: 14th Jul 2016 13:50
Quote: "before you were executing playsprite() every frame so it was always setting the animation to the first frame. you need a system where by playsprite is executed ONLY when the state changes"


Further to the above suggestion provided by blink0k, in its simplest form, you could do this...

if GetSpritePlaying(spr) = 0 Then PlaySprite(spr)
Using AppGameKit V2 Tier 1
Artformer
14
Years of Service
User Offline
Joined: 23rd Aug 2010
Location: Scotland
Posted: 14th Jul 2016 15:20
Ah, I see... then I have to say that AGK2 documentation is incomplete, to say the least! Thanks folks!

Login to post a reply

Server time is: 2024-11-22 03:53:02
Your offset time is: 2024-11-22 03:53:02