How can I change a picture to another picture on collision? In my game, there is an object that is falling, and I want the object to change to another picture when it hits another object. I already have the collision set up, I just want to know what to type where the collision starts. Here is what I have:
[code]
–START PHYSICS
local physics = require(“physics”)
physics.start()
–CREATE OBJECTS
local ball = display.newImage(“ball.png”)
physics.addBody( ball, { density=0.9, friction=0.3, bounce=0.3} )
local object = display.newImage(“object.png”)
–COLLISION
local function onLocalCollision( self, event )
if ( event.phase == “began” ) then
–CHANGE BALL TO “otherball.png”
end
end
ball.collision = onLocalCollision
ball:addEventListener( “collision”, ball )
object.collision = onLocalCollision
object:addEventListener( “collision”, object )
[/code] [import]uid: 38001 topic_id: 11280 reply_id: 311280[/import]
