1 2 3 4 5 |
-- first u need to declare the sheet data, mainly to tell corona about your sprite image format local sheetData = { width=162, height=214, numFrames=4, sheetContentWidth=648, sheetContentHeight=214 } -- then you create the sheet object, where you use the sheetData you specified above as parameters to create it local imageSheet = graphics.newImageSheet( "sprite.jpg", sheetData ) |
- width: width of the single frame 648/4 = 162 pixel
- height: always 214 pixel as our sprite image is a horizontally long image. There are more complicated cases where your sprite might be more than 1 row.
- numFrames: only 4 here as you can see
- sheetContentWidth: your sheet image size in width, is 648 pixel
- sheetContentHeight: same as above, but in height, is 214 pixel
1 2 3 4 5 6 7 8 9 |
local sequenceData = { name="cycling", start=1, count=4, time=1000, loopCount = 0, -- Optional ; default is 0 (loop indefinitely) loopDirection = "forward" -- Optional ; values include "forward" or "bounce" } |
1 |
local loadingSprite = display.newSprite( imageSheet, sequenceData ) |
1 2 3 4 |
loadingSprite.anchorX=0.5 loadingSprite.anchorY=0.5 loadingSprite.x = display.contentCenterX loadingSprite.y = display.contentCenterY |
1 |
loadingSprite:play() |