I’m to make an object explode on a collision.
The collsion works, I’m getting my explosion and sound, but no applyForce is occurring.
Thanks
[code]
local function onbarrelCollision ( self, event )
if ( event.force > 4 ) then
local forcex = event.other.x -self.x
local forcey = event.other.y -self.y - 20
print("event.other.x- "…event.other.x)
print("event.other.y- "…event.other.y)
print("forcex- "…forcex)
print("forcey- "…forcey)
event.other:applyForce( forcex, forcey, event.other.x, event.other.y )
explosionPoof.x = event.target.x
explosionPoof.y = event.target.y
explosionPoof.alpha = 0
explosionPoof.isVisible = true
if explosionpoofTween then transition.cancel( explosionpoofTween ); end
local explosionfadePoof = function()
transition.to( explosionPoof, { time=300, alpha=0 } )
end
explosionpoofTween = transition.to( explosionPoof, { time=100, alpha=1.0, onComplete=explosionfadePoof } )
if audioset == 1 then
audio.play( explosionSound )
end
self:removeSelf()
self = nil
end
end
– Set table listeners in each board to check for collisions
barrelwood.postCollision = onbarrelCollision
barrelwood:addEventListener( “postCollision”, barrelwood )
[/code] [import]uid: 78446 topic_id: 16534 reply_id: 316534[/import]
