Sprite sheet static image

hello :)

i need to change a image with a sprite sheet, i never used sprite sheets and need some help, i saw this code:

1
2
3
4
local tileSheet = sprite.newSpriteSheet("tiles.png", 64, 64)
local tileSet = sprite.newSpriteSet(tileSheet, 1, 10)
local tile = sprite.newSprite(tileSet)
tile.currentFrame = 5

local spriteSheet = sprite.newSpriteSheet( "sprite.png", 100, 100 )
--> means, each frame in sprite.png is 100x100 pixels size

local spriteSet = sprite.newSpriteSet (spriteSheet, 1, 4)
--> you are creating a sprite-set - that has '4' frames - starting from frame '1' - from the 'spriteSheet'

sprite.add (spriteSet, "play-frame-1-2-3", 1, 3, 1000, 1)
--> you are creating a sequence of frames to play
--> Here: you want to play '3' frames - starting from frame '1' , i.e. frame 1,2,3 - in 1000milli-seconds.
--> last parameter is how many time you want to play the same sequence. Here, '1' means it will play once.

local spriteInstance = sprite.newSprite( spriteSet )
spriteInstance:prepare ("play-frame-1-2-3")
spriteInstance:play()
--> now you will actually playing 'frame 1 2 3'

Hope it helps.

- Chinta

try using SpriteGrabber it makes working with spritesheets abit easier
http://developer.anscamobile.com/code/spritegrabber-spritesheets-two-lines

views:1433 update:2011/10/17 8:58:49
corona forums © 2003-2011