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 / ResumeSprite command

Author
Message
Brian Lancaster
10
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Oakland, CA
Posted: 18th Feb 2020 01:32 Edited at: 18th Feb 2020 01:37
Is there an easier way to do this without adding more confusing variables every time a sprite starts/stops it's animation? I'm making some like a poor-man's Baldur's Gate and I want the SPACE bar to pause/unpause the screen. But I get the error when I use the resumeSprite() command because I never used stopSprite() with some of them. I could do it with variables, but I really don't wanna make the source code any more complex.

I want a command like getSpriteStopped() or something. Is there something stupid I'm overlooking?

Thanks.

fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 18th Feb 2020 04:09
Returns 1 if the sprite is currently playing an animation, 0 if not.
integer GetSpritePlaying( iSpriteIndex )

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 18th Feb 2020 15:04
It's difficult to give a solution without a bit more context to your code, as it doesn't provide any details as to how you're playing your sprites in the first place -- whether they are at different frame rates, loop statuses etc. But, assuming you're keeping it as simple as possible and only using PlaySprite() with no arguments for frame rate, start/end frames or looping, and not setting frames manually beforehand, you could use a GetSpriteCurrentFrame() check to see if the current frame is 1. It stands to reason that if you haven't actually started playing the sprite with PlaySprite(), that's what it will be. If that's the case, then use PlaySprite() instead of ResumeSprite().

Brian Lancaster
10
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Oakland, CA
Posted: 23rd Feb 2020 03:08
Thank you, Hendron. GetSpriteCurrentFrame() was a simple fix.

Login to post a reply

Server time is: 2024-11-22 11:18:37
Your offset time is: 2024-11-22 11:18:37