I have 2 issues
#1 the platform “collusion” never fires when it hits the left or right walls.
I have a different object that slides left and right with the transition.to and it fires the collusion functions for it.
Even if i change the platform to use transition.to is still does not fire the collision event.
#2 the platform is 100 pixels wide and i guess because the default reference point is display.CenterLeftReferencePoint it using that as it’s x position. So ( not depicted below ) in the move i actually have to calculate based on platform.x+50 or x-50 to keep the platform image in the focus of the screen, why is that?
I have hybrid mode on and can see the walls that the platform pass right through.
[code]
local leftwall = display.newRect(0,0,1, display.contentHeight)
local rightwall = display.newRect(display.contentWidth,0,1, display.contentHeight)
local ceiling = display.newRect(0,0, display.contentWidth,1)
physics.addBody(leftwall, “static”, {density=3.0,bounce = 0.1} )
physics.addBody(rightwall, “static”, {density=3.0, bounce = 0.1} )
physics.addBody(ceiling, “static”, {density=3.0,bounce = 0.1} )
local xdirection = 10
local movePlatform = function()
if (platform.x <= 0) then xdirection = 10 end
if (platform.x >= display.contentWidth) then xdirection = -10 end
platform.x = platform.x + xdirection
end
–This even NEVER fires
–local function onPlatformCollision( self, event )
local function onPlatformCollision( event )
t:setText( “onPlatformCollision-” );
if (event.object1.x <= 0) then xdirection = 10 end
if (event.object1.x >= display.contentWidth) then xdirection = -10 end
platform.x = platform.x + xdirection
end
platform.isAwake=true
platform.isSleepingAllowed = false
platform.collision = onPlatformCollision
platform:addEventListener( “collision”, platform )
–platform:addEventListener( “collision”, onPlatformCollision )
Runtime:addEventListener( “enterFrame”, movePlatform )
[/code] [import]uid: 11860 topic_id: 4515 reply_id: 304515[/import]