[lua]apple = {}
for i = noOfApple, 1, -1 do
rarity = mRand(100) --random number from 1 to 100
apple[i] = {}–dynamically create 2D table
if (rarity > 50) then
apple[i].type = red
apple[i] = display.newImageRect(“APPLE_RED.png”, 75, 85)–Red Apple
apple[i].xScale = .5; apple[i].yScale = .5
physics.addBody( apple[i], “dynamic”, {density= 0.01, friction=0.5, bounce=0.15, shape=appleShape } )
apple[i].x = mRand(_W * 0.05,_W * 0.95)–random x postion of apple
apple[i].y = mRand(-(_H * (mRand(1,4) * 0.1)), _H * 0.1)–random y postion of apple
else
apple[i].type = green
apple[i] = display.newImageRect(“APPLE_GREEN.png”, 75, 85)–Green Apple
apple[i].xScale = .5; apple[i].yScale = .5
physics.addBody( apple[i], “dynamic”, {density= 0.01, friction=0.5, bounce=0.15, shape=appleShape } )
apple[i].x = mRand(_W * 0.05,_W * 0.95)–random x postion of apple
apple[i].y = mRand(-(_H * (mRand(1,4) * 0.1)), _H * 0.1)–random y postion of apple
end
end
[lua]the number of apple generated will fall from a random x and y axis but how do i make it disappear by tapping on the apple?
How do i create listener for a table object using object:removeSelf() [import]uid: 40786 topic_id: 8326 reply_id: 308326[/import]