I’ve a sprite with around 300 frames of size 40x20.
These frames are related (e.g. different type of coffee drinks) but are not animation, I want to pick one frame/image and display it on one screen, then display another frame on different screen or display two frames on the same screen.
local sheet = sprite.newSpriteSheet(“coffeetypes.png”, 40, 20)
function getFrame(frameNumber)
local spriteSet = sprite.newSpriteSet(sheet, frameNumber, 1)
sprite.add(spriteSet,“coffeedrink”,1, 1, 1000, 1)
return sprite.newSprite(spriteSet)
end
function displayFrame(frame)
frame:prepare(“coffeedrink”)
frame:play()
end
1> I want to display only one frame from the sprite. Is this solution correct? Or there is a better way of doing it.
local f = getFrame(1)
displayFrame(f)
2> I want to avoid loading and unloading image
(i.e. avoid calling multiple times sprite.newSpriteSheet(“coffeetypes.png”…)
3> When do I call spriteSheet:dispose()?
4> Will there be a problem if I call (in terms of memory leaks or something…)
displayFrame(getFrame(1))
displayFrame(getFrame(2))
displayFrame(getFrame(1))
[import]uid: 45045 topic_id: 9193 reply_id: 309193[/import]