How to respawn in table array?

Hi folks,

I guess this is an easy one - but I haven't figured out to do this...

I am having all my images in an array (table) called bricks. I have built up my dummy game with regular rectangles, but I am now changing those to images that looks more nicer. I am almost done, but how should I respawn the following object "bricks[j]" with an image, and with correct x,y axis?

1
2
3
4
5
6
if(oldColor==1 and color==3) then
  --> old code to access the object and change fill color
  bricks[j]:setFillColor(255,255,0)
 
end
                                                                

OK, some more code...

This is the spawn function

1
2
3
4
5
6
7
8
9
10
11
12
function spawn(x,y,myx,myy)
        local brick = display.newImageRect( "b_lightblue.png", 128,128)
        brick.x = x
        brick.y = y
        brick.myX = myx
        brick.myY = myy
        brick.index = #bricks + 1
        Scene:insert(1,brick)
        bricks[brick.index] = brick
    
        return object
end

Solved, I removed the previous respawned object, and readded it. Sometimes things are easier then you are aware of :)

Joakim

views:1375 update:2011/10/19 14:58:09
corona forums © 2003-2011