Simplest way to swap sprite flames?

SGDK only sub forum

Moderator: Stef

Post Reply
POLYGAMe
Very interested
Posts: 144
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Simplest way to swap sprite flames?

Post by POLYGAMe » Wed Apr 13, 2016 6:52 am

The sprite engine animation is overkill for what I need. I just want to swap the image of my sprite when I press a joystick direction. What's the best way to do this? Which function should I be calling? I haven't been able to work it out from the docs. Sorry for the super noob question!

Stef
Very interested
Posts: 2976
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Simplest way to swap sprite flames?

Post by Stef » Wed Apr 13, 2016 8:02 am

Try to use the VDP_setSpriteXXX(...) methods, they allow you to manipulate sprites at low level :)

POLYGAMe
Very interested
Posts: 144
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Re: Simplest way to swap sprite flames?

Post by POLYGAMe » Wed Apr 13, 2016 10:22 am

Cool. I thought that might be slower, like setting your tile map every frame instead of scrolling. I guess im just getting used to how the VDP works. I'll have a play on the weekend. Thanks for your help again!

POLYGAMe
Very interested
Posts: 144
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Re: Simplest way to swap sprite flames?

Post by POLYGAMe » Sun Apr 24, 2016 5:56 am

I can't work it out... I can't see in any of those functions where I can change the tile index of my sprite sheet to change frame...

EDIT: I worked out how to do it with SetFrame.

I was looking in the sprite project and I understand how the animations work (how it runs through each row as an animation and you change rows to switch animations) but I couldn't find where the actual animations are set up... sequence, speed etc... it's not in the source file so is it maybe the default settiong in the sprite engine itself?

Stef
Very interested
Posts: 2976
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Simplest way to swap sprite flames?

Post by Stef » Sun Apr 24, 2016 8:01 am

I though you didn't wanted to use the Sprite Engine ?
If you use the low level VDP_setSpritexxx methods you don't have direct way of giving the frame to display... you have to deal with that yourself by modifying the attributs of your sprite.
In the Sprite Engine you indeed have a setFrame method for that.

POLYGAMe
Very interested
Posts: 144
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Re: Simplest way to swap sprite flames?

Post by POLYGAMe » Mon Apr 25, 2016 12:18 am

Yeah I decided I'd use the engine as some objects will require more animation. I'm struggling to see how to use animations in the sprite demo. I see where they're defined but not how they're implemented. I can write my own using timers and SetFrame etc but I just wasn't sure if that was the 'proper' way. As I said I can't see in the sprite demo how the frames or speed of the Sonic sprite are done...

So yeah I have it working now just wondering if there's a simpler way like plugging in the sequence frames and speed or do I need to code my own system to do that instead of the hard coding I'm using now?

Stef
Very interested
Posts: 2976
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Simplest way to swap sprite flames?

Post by Stef » Mon Apr 25, 2016 9:35 am

Currently rescomp handle animation in a very simple way. You have to display each frame inside the sprite sheet, if you have duplicated frames rescomp should detect them and generate the "sequence" array according... About the timer, that is the last parameter in the SPRITE resource definition, i believe i used '5' in the "sprite" demo so each frame is automatically maintained 5 frames before going to the next one.
Again that is very basic, i really need a more advanced tools as the underlying Sprite structures and the Sprite Engine are very flexible but rescomp use them in a very limited way.

POLYGAMe
Very interested
Posts: 144
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Re: Simplest way to swap sprite flames?

Post by POLYGAMe » Mon Apr 25, 2016 9:51 am

Ah, got it! Thanks :) For my player I just need SetFrame but I'll need full animation soon. Thanks!

Post Reply