So right now I have a block on top of a platform and when you click him, force is applied to him and he moves left. It works… most of the time. But then sometimes it doesn’t work. I click him and he won’t move at all or something seams to keep him stuck there.
There are other things going on like I have another cube doing the same thing except going up. If you have anymore questions on this, ask me.
**Edit: It’s not actually the collision. I put him in the air and sometimes the gravity in the physics brings him down onto the platform but other times he gets stuck in the air. Almost like it freezes but the other cube that moves can move up. That cube goes through another object which he normally collides with (when the first cube can move).
Here is an example of the code I used:
[code]
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
local physics = require “physics”
physics.start()
function scene:createScene( event )
local group = self.view
local movementCube = display.newImageRect( “GameImages/movementCube.png”,40, 40 )
movementCube.x, movementCube.y = 390, 163
local function onMoveCubeTap( event )
movementCube.angularVelocity = 100
movementCube:applyForce( -700, 0, movementCube.x, movementCube.y )
end
movementCube:addEventListener( “tap”, onMoveCubeTap )
physics.addBody( movementCube, { density=1.0, friction=0.3, bounce=0.3 } )
local platform = display.newImageRect( “GameImages/platform.png”, 283, 38 )
platform:setReferencePoint( display.CenterReferencePoint )
platform.x, platform.y = 300, 200
local platformShape = { -141,-18, 141,-18, 141,18, -141,18 }
physics.addBody( platform, “static”, { friction=0.3, shape=platformShape } )
group:insert( platform)
group:insert( movementCube)
end
function scene:enterScene( event )
local group = self.view
storyboard.removeScene( “restart” )
storyboard.removeScene( “level1” )
storyboard.removeScene( “menu” )
physics.start()
end
function scene:exitScene( event )
local group = self.view
physics.stop()
end
function scene:destroyScene( event )
local group = self.view
package.loaded[physics] = nil
physics = nil
if restartButton then
restartButton:removeSelf()
restartButton = nil
end
if menuButton then
menuButton:removeSelf()
menuButton = nil
end
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )
return scene
[/code] [import]uid: 114174 topic_id: 26150 reply_id: 326150[/import]
[import]uid: 114174 topic_id: 26150 reply_id: 106165[/import]