0

Hello in a game I'm making using lua in Marmalade Quick,I have run into a problem with the physics.

I have a normal downward y gravity and have some notes that is affected by that. Now I want to add some objects that "fly" horizontally on the X axis but I can not get it to work.

so one of the notes looks like this:

    sky2 = director:createSprite(dw, 40, "textures/tractor.png")
    physics:addNode(sky2, {type="dynamic"})
    sky2.physics:setGravityScale(0)

my first thought was to just add the following to an update listener

if(gameplaying == true) then
      sky2.x = sky2.x-2.5 

unfortunately this does not work after the node has got added physics

then I was looking into using

sky2.physics:applyapplyLinearImpulse or sky2.physics:applyForce

I used it like this

sky2.physics:applyapplyLinearImpulse(-10, 0, -20, 40)

The problem here is that the node then correctly moves along the axis but it is spinnig around (torque effects)..

Is there away to stop this or what am I doing wrong,,

thanks..

4

1 回答 1

1

发现 Marmalade Quick Documentation 是错误的,并且不输入 px 和 px 值,而只输入 0,因此sky2.physics:applyapplyLinearImpulse(-10, 0)这将在质心处应用脉冲并使其直线移动。

于 2014-01-08T19:02:33.563 回答