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.



+ Code Snippet
    gShipImage = loadImage("Lunar\shipSheet.png")
    gShip = createSprite(gShipImage)
    `SetSpriteScale(gShip,0.25,0.25)
    `SetSpriteSize(gShip,32,32)
    setSpriteAnimation(gShip,3,6,18)
    setSpriteFrame(gShip,1)
    playSprite(gShip)
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!
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.
Posted: 8th Oct 2011 23:30
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?
Posted: 9th Oct 2011 0:01
My bad, I was using the number of sprites, not the width/height of sprites.

Many thanks!