@espace3d,
Sorry, are you saying it still fails for you? I see from your image that it looks wrong.
Here is some modified code (uses a side-effect of physics rendering code to show the center of the object):
local physics = require "physics" physics.start() physics.setGravity( 0, 0 ) physics.setDrawMode( "hybrid" ) local character = display.newCircle( 160, 240, 30 ) character:setFillColor(1,0,0) physics.addBody( character, { radius = 30, isSensor = true } ) local onTouch = function( self, event ) if(event.phase == "began") then print ( self.x, self.y ) transition.to( character, { x=self.x, y=self.y, time = 1000 } ) print("Moving character to ", self.x, self.y ) timer.performWithDelay( 1500, function() print("character at", character.x, character.y ) end ) end return true end local function makeGridObject( group, x, y, color ) group = group or display.currentStage -- allows this call: makeGridObject( nil, 10, 10, {1,1,1} ) local tmp = display.newCircle( group, x, y, 20 ) tmp:setFillColor(unpack(color)) tmp.touch = onTouch tmp:addEventListener( "touch" ) physics.addBody( tmp, { radius = 20 } ) end local objs = display.newGroup() makeGridObject( objs, 10, 10, {1,1,0} ) makeGridObject( objs, 50, 50, {1,0,1} ) makeGridObject( objs, 200, 200, {0,1,1} )
Please note, this will only work like this for recent Corona builds (I’m using 2014.2370), so if you’re using an old one it may not behave as in this video (watch in HD full screen to see the centers):
https://www.youtube.com/watch?v=34lffgSDlfo&feature=youtu.be&hd=1
Whatever the case, if you get misaligned transitions and one of the following is true, you shouldfile a bug:
- You are using the 2014.2189a
- You are using the latest Pro or Enterprise daily build.
If you’re using another version of Corona, you should update to the latest your license allows for. Again, if at that point you can’t get this to work file a bug report (with the above code).
Cheers,
ed