Please HELP! I do high speed action platformer, something like Contra, but even more rapid. I have a problem with impulses: some objects must did not get impetus from the other objects. Here is a sample code. Then the player gets a boost from the platform, but it should not.
-- start physics
local physics = require( "physics" )
physics.start()
physics.setGravity( 0, 10 )
physics.setDrawMode( "hybrid" ) -- hybrid, debug
-- creates a moving platform
local platform = display.newRect( 0, 0, 200,150 )
platform:setFillColor( 155, 155, 255 )
physics.addBody( platform, "kinematic", { friction=0.1, bounce=0.1, density=12 } )
platform.x, platform.y = 200, 700
-- create "player"
local player = display.newRect( 0, 0, 60, 60 )
player:setFillColor( 245, 215, 245 )
physics.addBody( player, "dynamic", { friction=0.1, bounce=0.1, density=12 } )
player.x, player.y = 200, 650
-- move the platform
local j=0
local function movePlatform()
j=j+1
if j==30 then
-- stop the platform, but player is still moving....
platform:setLinearVelocity(0,0)
platform.x, platform.y = 200, 700
elseif j==60 then
platform:setLinearVelocity(0,-200)
j=0
end
end
Runtime:addEventListener( "enterFrame", movePlatform )
P.S.:
I could not simplify the game. Platforms are many and they complex. In addition here is a lot of monsters. Not all the forces that act upon the world must act on the player.
[import]uid: 26141 topic_id: 29898 reply_id: 329898[/import]
You are the one who tries to help me on this forum