In my code below, I’m spawning a new object when a button is pressed. I’d like to also create a health value for each object in the table so something like allkernel[i].health = 20 so that later on, something can reference the health value of each spawned object. I’m not sure how I associate each object with a health value though.
local function spawnkernel( event )
local phase = event.phase
if "ended" == phase then
allkernel[#allkernel + 1] = display.newImage( "cernal.png" )
local disk = allkernel[#allkernel]
disk.x = math.random (150, 270)
disk.y = 50
disk.rotation = math.random( 1, 360 )
physics.addBody( disk, { density=50, friction=3, bounce=0, radius=15 } )
disk.linearDamping = 0.4
disk.angularDamping = 0.6
end
end
Thanks,
[import]uid: 78150 topic_id: 16184 reply_id: 316184[/import]
[import]uid: 3826 topic_id: 16184 reply_id: 60284[/import]