How Do I Change/swap An Image Object/variable?

Hi,

I have a very simple, newbie question… if i have in my .lua file the following:

local myImage = display.newImageRect("myImage.png", sW,sH,true); myImage.x=sW/2; myImage.y=sH/2

Later, in that same .lua file, I want to switch the graphic - but still using the same variable name of “myImage” - to another graphic, say, myImage2.png how do i change it? Or do i have to use a spritesheet for this? I’m trying to avoid 1) using spritesheet because potentially the size of it may get too large to support (because of ipad retina size and the graphic fills the whole screen) and 2 )trying to avoid creating a new variable in the file like “local myImage2 = display.new…”

Is there something similar to for example changing text, where you can use:

myText.text="This is my new text."

Is there something similar but for graphic objects? I gather i can’t do this:

myImage = display.newImageRect("myImage2.png", sW,sH,true)

In this case, i want to avoid spritesheets, any ideas? I couldn’t find anything on Google search or the docs.

Thanks

Currently, there is no method except described on my feedback request. Please vote it now below to get it implemented soon. I’ve already spoken to the engineers about this.

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/3814545-be-able-to-change-a-display-object-s-image-as-easy

Ah ok, thanks - and done! Hmm, guess i’ll have to think how i want to (try and) implement this…

Cheers,

You might try sprites, without play()-ing them and switching the frame.

C

Currently, there is no method except described on my feedback request. Please vote it now below to get it implemented soon. I’ve already spoken to the engineers about this.

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/3814545-be-able-to-change-a-display-object-s-image-as-easy

Ah ok, thanks - and done! Hmm, guess i’ll have to think how i want to (try and) implement this…

Cheers,

You might try sprites, without play()-ing them and switching the frame.

C

Really, we cannot switch an image.

I use sprites elsewhere but it is very time consuming to make them, especially for a simple swap image.

It is getting the alignment right in the sprite png and then writing the sprite file.

I know there are tools but i have not yet bought the paid version of texture packer and for 2 images, it watermarks them.

Can anyone suggest an easy way to make a sprite and sprite sheet for 2 images.

Thanks,

Don’t forget to vote! Click here, I’ll send this up the pipe ASAP.

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/3814545-be-able-to-change-a-display-object-s-image-as-easy

Hi, I have voted for the feature.

I have also set up my sprite sheets.

I have 4 buttons and i want an on/off state for them.

Can anyone tell me what i need to do in my event listener… i have set up 2 sequences.

Thanks

Really, we cannot switch an image.

I use sprites elsewhere but it is very time consuming to make them, especially for a simple swap image.

It is getting the alignment right in the sprite png and then writing the sprite file.

I know there are tools but i have not yet bought the paid version of texture packer and for 2 images, it watermarks them.

Can anyone suggest an easy way to make a sprite and sprite sheet for 2 images.

Thanks,

Don’t forget to vote! Click here, I’ll send this up the pipe ASAP.

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/3814545-be-able-to-change-a-display-object-s-image-as-easy

Hi, I have voted for the feature.

I have also set up my sprite sheets.

I have 4 buttons and i want an on/off state for them.

Can anyone tell me what i need to do in my event listener… i have set up 2 sequences.

Thanks