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 / PlaySprite Issue...

Author
Message
bstebbs
11
Years of Service
User Offline
Joined: 10th Jan 2013
Location:
Posted: 16th Dec 2013 04:31
Wanted to share a PlaySprite issue and how I got around it.

I'll use pseudo code to demonstrate what I was doing...

//Create a Sprite and animate it
CreateSprite(1,0)
AddSpriteAnimationFrame (1, LoadImage("1.png",1))
PlaySprite(...)

//Create a JoyStick that will control the animated sprite
JoyStick = CreateSprite(LoadImage("JoyStick.bmp",1))

Do
If JoyStick is pressed, ResumeSprite (1)
If JoyStick is not pressed, StopSprite (1)
Sync()
Loop

So when I come into the Do Loop, the sprite is already created, animation frames set up, and it's animated. Then, any time the JoyStick is not pressed, it stops the animation and any time the JoyStick is pressed, it resumes the animation. However, when it's set up this way, the sprite animation never happens. The sprite moves like I want it using my JoyStick sprite but there's NO animation.

To fix this problem, I put the PlaySprite command in the JoyStick is pressed section so I turn it on the first time I've pressed the JoyStick sprite. Then, every time after that, I issue the ResumeSprite in the JoyStick is pressed section and StopSprite in the JoyStick is not pressed section and it works perfectly. And, that's how I want it to work anyway. Thought I'd share for those who could use this help.
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 16th Dec 2013 10:37
bstebbs, if I understand you correctly, I think the issue may have been that you were either using PlaySprite or ResumeSprite without first checking to see if the animation was already playing. This is essential (whilst in the main loop), otherwise you are effectively calling PlaySprite/ResumeSprite every loop which starts the animation from the beginning thus never moving from the first frame...

If you were to add GetSpritePlaying(1) = 0 before triggering PlaySprite/ResumeSprite, you would probably be ok...

I've made a few assumptions there as I haven't seen your code, but I am pretty certain there are no issues with PlaySprite. If you post your actual code, I'd be happy to take a look...

Login to post a reply

Server time is: 2024-11-24 23:21:23
Your offset time is: 2024-11-24 23:21:23