event.x seems to not work

I have this scene, I want when the earth collide with the blackhole an explosion sprite to be played.

ORCmO.png

So I wrote this:

local function onCollision( event ) if ( event.phase == "began" ) then if(event.object1.name =="blackholeSprite" or event.object2.name =="blackholeSprite") then explosionSprite.x=event.x explosionSprite.y=event.y explosionSprite:play() timer.performWithDelay( 1500, gameOver ) end end end

The problem is that the explosion does not occur where the ball and the blackhole collide event.x andevent.y . As you can see from the screenshot the explosion take place in the top-left corner. Any idea why this happens?

Perhaps instead of event.x/event.y you can just use event.object1.x and event.object1.y?  

Try using:

physics.setReportCollisionsInContentCoordinates( true )

to get the cordinates in content space.

I have the same thing. You only use collision.x=(event.object1.x+ event.object2.x)/2 and the same for y?

Is this a question or a suggestion? I haven’t use this, but I will try it when I return home. 
 

Any example/tutorial on how this really works?

It didn’t really works. Thx anyway.

What kind of example project do you need for this?

Just do it like this:

local physics = require("physics") physics.start() physics.setReportCollisionsInContentCoordinates( true )

If you now have a collision, you don’t get the event.x, event.y in relation to colliding object, instead you get in relation to the parent object the colliding object is in.

Just try around with it a bit.

thx, I get it

Perhaps instead of event.x/event.y you can just use event.object1.x and event.object1.y?  

Try using:

physics.setReportCollisionsInContentCoordinates( true )

to get the cordinates in content space.

I have the same thing. You only use collision.x=(event.object1.x+ event.object2.x)/2 and the same for y?

Is this a question or a suggestion? I haven’t use this, but I will try it when I return home. 
 

Any example/tutorial on how this really works?

It didn’t really works. Thx anyway.

What kind of example project do you need for this?

Just do it like this:

local physics = require("physics") physics.start() physics.setReportCollisionsInContentCoordinates( true )

If you now have a collision, you don’t get the event.x, event.y in relation to colliding object, instead you get in relation to the parent object the colliding object is in.

Just try around with it a bit.

thx, I get it