how can I copy the instance of "display.newImage"

Hi. I’m stuck in a trouble of image copying.
I learned how to create new image object by display.newImage.
But I don’t know how to copy it.
I’m making 2D-RPG. Think about map-chips, they need multiple
images like floor, ground, sea, forest…whatever.

I don’t want to load same image path many times.
So, I tried to copy the image object as hImage2, and tried to translate…
but, the result is, only hImage1 is displayed in (200, 400) position.

local hImage1 = display.newImage( “floorChip.jpg” )
local hImage2 = hImage1 --copy
hImage1.x = 0
hImage1.y = 0
hImage2.x = 200
hImage2.y = 400

How can I copy hImage1 to hImage2?
Or is there another way to display a number of “floorChip.jpg” with one time loading? [import]uid: 98774 topic_id: 17681 reply_id: 317681[/import]

You could use some sort of for loop that uses multiplication to determine the x and y coordinates.

Edit: I’m sure there’s some bugs with this, but it might help.
[lua]local number
local xCoord = 0
local yCoord = 0

for number = 0, 2 do
local hImage1 = display.newImage(“floorChip.jpg”, xCoord, yCoord)
xCoord = 200
yCoord = 400
end[/lua] [import]uid: 103624 topic_id: 17681 reply_id: 67283[/import]

@kilocinema

Thank you. But I already know that method.
This is the exactly same meaning like this.
[lua]local hImage1 = display.newImage( “floorChip.jpg” )
hImage1.x = 0
hImage1.y = 0
local hImage2 = display.newImage( “floorChip.jpg” )
hImage2.x = 200
hImage2.y = 400[/lua]

This method seems to be good.
But if I make RPG, I need to call display.newImage for around 30 patterns tiles
(e.g floorChip.jpg, wallChip.jpg, riverChip.jpg…and so on) every each field.
If I create 30 patterns tiles in a 15*20 field, then I need display.newImage 9000 times!

Plus, RPG needs map-scrolling and map-switching.
So, I need another way to create&load maps in a faster way. [import]uid: 98774 topic_id: 17681 reply_id: 67294[/import]

Take a look at Lime. (There’s a sub forum for it.)

That could be what you’re looking for :slight_smile: Great for RPGs.

Peach [import]uid: 52491 topic_id: 17681 reply_id: 67377[/import]