Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Is there a way to update the location of an image?

I'm currently calling my image dynamically using:

itemImage = display.newImage(inventory[t.ID][1])

t. being my target ID.

But in order for Storyboard to properly work, I need to change its location in my code to above my function, rendering its dynamic properties useless. Is there a way to update it like you can do with .text?

something along the lines of:

itemImage.image(inventory[t.ID][1])
itemImage.imageUpdate(inventory[t.ID][1])

etc...

share|improve this question

2 Answers 2

No. You have two options.

Firstly, you can remove the image and then request the next one.

display.remove(itemImage)
itemImage = nil
local myOtherImage = display.newImageRect()

If you call the old image again later, this is fine as the images are cached by Corona.

Secondly, you can use an image sheet:

display.remove(imageItem)
itemImage = nil
local myOtherImage = display.newImageRect(imageSheet, frame, width, height)

This allows you to pull images from an efficiently packed image sheet.

I must admit I don't fully understand what you are trying to accomplish. There is no reason you should be struggling with this and storyboard. Perhaps post a few more details with the specific problem.

As a side note, you should try and use newImageRect as this allows for scaling:

http://docs.coronalabs.com/daily/api/library/display/newImageRect.html

share|improve this answer

Have you tried using transition.To?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.