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 / Process for animating and scaling a sprite?

Author
Message
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Oct 2011 18:13
I'm struggling with this combination. I need to load a sprite sheet as an image, make the sprite and also resize it.

Even if I don't resize, I get a nonsensical animated sprite, it just flickers from transparent to solid white. The code below has 2 commented out attempts at resizing. Without the resize, I still get an unrecognisable sprite.





Grumpy Jedi
14
Years of Service
User Offline
Joined: 16th Jan 2010
Location:
Posted: 8th Oct 2011 18:30
Unless your ship is only 3 pixels wide by 6 pixels high then your using the SetSpriteAnimation command incorrectly.

You should be using it like this...

SetSpriteAnimation(gShip,WidthOfEachAnimationFrame,HeightOfEachAnimationFrame,TotalNumberOfAnimationFrames)

Lets say for instance you have a 512x512 sprite sheet, that has a 4x4 grid of animation frames. That would make each frame 128x128, with a total of 16 frames. Your code would look like this.

SetSpriteAnimation(gShip,128,128,16)

The SetSpriteFrame command isn't necessary as it will default to 1 anyway.

Good Luck!
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 8th Oct 2011 21:51
When using animated sprites and atlas textures you have to also make sure you use ^2 sprites eg. 1,2,4,8,16,32,64.... Otherwise on some netbooks and I guess phones as well, you will have odd bugs. 3x6 for instance would work on my main system, but transfer to a netbook and bang it would pad itself and cause incorrect anims.

Grumpy Jedi
14
Years of Service
User Offline
Joined: 16th Jan 2010
Location:
Posted: 8th Oct 2011 23:30
Quote: "When using animated sprites and atlas textures you have to also make sure you use ^2 sprites eg. 1,2,4,8,16,32,64.... Otherwise on some netbooks and I guess phones as well, you will have odd bugs. 3x6 for instance would work on my main system, but transfer to a netbook and bang it would pad itself and cause incorrect anims."


I was under the impression that if images assigned to a sprite were not a power of 2, AppGameKit would pad them, but then reduce the UV coordinates so it only used the portion containing the original image and not the padding...

The documentation seems to support that as well...

Is that not the case?
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 9th Oct 2011 00:01
My bad, I was using the number of sprites, not the width/height of sprites.

Many thanks!

Login to post a reply

Server time is: 2024-03-28 18:19:18
Your offset time is: 2024-03-28 18:19:18