I have an object which has a default image applied. After a period of time I want the image to change to show degradation or some other effect.
Is there some way of change an existing objects image or do you make a copy of all the parameters but the image and change it that way?
Or as a complete alternative am I dealing with sprite sheets? The reason I think not is that I am not thinking of a animated sequence but based on certain certain time or event.
Your help would be appreciated
I'm doing that with sprite sheets.
Sprites don't have to be constantly animated.
e.g. 6 levels of degradation: just change the frame of the sprite from 1 thru 6 as it degrades.
Easy.
require "sprite"
tilesheet = sprite.newSpriteSheet("tiles.png", 40, 40)
tileset1 = sprite.newSpriteSet(tilesheet, 1,6 )
local thing = sprite.newSprite( tileset1 )
thing.currentFrame = 3; --or whatever
you can use movieclip also if you prefer not to create a spritesheet from your images.
1
| local images= movieclip.newAnim{ "image1.png","image2.png"} |
To control by time, you can also use the timer.performWithDelay.
local function change_frame()
images:stopAtFrame(2)
end
thetimer = timer.performWithDelay( 1000, change_frame, 0 )
1000 is time in millsecond
chang_frame is the function you want to call
0 is the number of loop
hope this help.
Thank you all for getting back to me so quickly these are all great suggestions
I'll give sprite sheets a go and let you know how I get on