Changing images during runtime

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 [import]uid: 103970 topic_id: 19488 reply_id: 319488[/import]

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 [import]uid: 108660 topic_id: 19488 reply_id: 75161[/import]

Sprite sheets is probably the best way to go : http://developer.anscamobile.com/reference/index/sprite [import]uid: 84637 topic_id: 19488 reply_id: 75169[/import]

you can use movieclip also if you prefer not to create a spritesheet from your images.

[lua]local images= movieclip.newAnim{ “image1.png”,“image2.png”}[/lua]

then you can set the images using

[lua]images:stopAtFrame(1)
images:stopAtFrame(2)[/lua]

PS: don’t forget to add movieclip.lua file to the apllication folder. [import]uid: 71210 topic_id: 19488 reply_id: 75183[/import]

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. [import]uid: 94613 topic_id: 19488 reply_id: 75205[/import]

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 [import]uid: 103970 topic_id: 19488 reply_id: 75255[/import]