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 / Extra Spritesheet control

Author
Message
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 28th Sep 2017 20:44 Edited at: 28th Sep 2017 22:18
Hey,

Inspired by my own advice in the Visual Editor thread, I've written some code to give more control over spritesheets.
Well ... sort of. The amount of control is the same but you can store animations in an XML file and then play them by animation name.

An example XML file for a simple four animation spritesheet:


You can use that to play an animation from the spritesheet with:
PlaySpriteSheet( sheetID, animID )
or
PlaySpriteSheet(girl, GetAnimID(girl, "right"))
I've attached the code with example sprites.
Give it a go - its better than it sounds

Attachments

Login to view attachments
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 28th Sep 2017 22:15 Edited at: 28th Sep 2017 22:17
Ultimately it comes down to two commands. One to load the sprite sheet - which extracts all the data fom the XML and one to play the sprite animation:
girl = LoadSpriteSheet("girl.png")
PlaySpriteSheet(girl, GetAnimID(girl, "right"))


Here is the Sprite Sheet code:

You can #include that in your project but you will need some of my other files #included too. The rar file in the post above has everything in a nice stand-alone package. including two sprite sheets to demonstrate the functionality.
pugmartin
21
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 29th Sep 2017 09:21
Dont need this myself at this point yet mate but will say looks very cool and good of you to put out to everyone.
Brilliant.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Oct 2017 20:53 Edited at: 7th Oct 2017 21:02
XML is a great way to store and use information like that Scraggle

I have become lazy I must admit and haven't used XML with tier 1 before
This is incentive to all of us to include and use other such files such as XML

I did plan on moving across to tier 2 and started one project
but apart from the normal errors I received I managed to get it to work without any templates working
just to convert a program to increase a few frame rate I've put that aside and into my todo basket

I have developed in GDK which I loved before and plan to go back to that too and fix some of the new Direct x
issues an old project now has due to changing and nolonger supported DLLs and Libs
fubar

Login to post a reply

Server time is: 2024-04-19 15:56:14
Your offset time is: 2024-04-19 15:56:14