@gaarathebest_94,
Are you thinking of one-way platforms?
See this short video. (From SSKCorona Sampler).
If so, here is the code that does the work:
[lua]local Corona_build = tonumber(system.getInfo( “build” ))
local function onCollision( self, event )
if(event.phase == “ended”) then
if(Corona_build < 2012.890 ) then
event.target.isSensor = false --(for versions before 890)
else
event.contact.isEnabled = true --(for versions 890 and after)
end
end
return true
end
local function onPreCollision( self, event )
if(event.target.y < event.other.y) then
if(Corona_build < 2012.890 ) then
event.target.isSensor = true --(for versions before 890)
else
event.contact.isEnabled = false --(for versions 890 and after)
end
else
if(Corona_build < 2012.890 ) then
event.target.isSensor = false --(for versions before 890)
else
event.contact.isEnabled = true --(for versions 890 and after)
end
end
return true
end
– …
createPlayer = function ( x, y, size )
player = ssk.display.rect( layers.content, centerX, screenBot-20-size,
{ size = size, myName = “thePlayer”, fill = _BLUE_,
stroke = _WHITE_, strokeWidth = 2, },
{ isFixedRotation = false, friction = 1.0, bounce = 0.0,
linearDamping=0.45, bodyType = “dynamic”,
colliderName = “player”, calculator= myCC } )
return player
end
createPlatform = function ( x, y, width, height )
local platform = ssk.display.rect( layers.content, x, y,
{ width = width, height = height, myName = “aPlatform”,
fill = _YELLOW_, stroke = _WHITE_, strokeWidth = 2, },
{ isFixedRotation = false, friction = 0.0, bounce = 0.0,
linearDamping=0.45, bodyType = “static”,
colliderName = “platform”, calculator= myCC } )
platform.collision = onCollision
platform.preCollision = onPreCollision
platform:addEventListener( “preCollision”, platform )
platform:addEventListener( “collision”, platform )
return platform
end[/lua]
Note: There are some calls the to the SSKCorona library in here, but what you really want is the onCollision()/onPreCollision() code.
Cheers,
Ed [import]uid: 110228 topic_id: 32786 reply_id: 130469[/import]