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..

Kasper S Mathiesen
  • 669
  • 1
  • 7
  • 17

1 Answers1

1

Found out that the Marmalade Quick Documentation was wrong, and to not input both a px and a px value but just 0 so sky2.physics:applyapplyLinearImpulse(-10, 0) this will apply the impulse at the centre of mass and make it move straight.

Kasper S Mathiesen
  • 669
  • 1
  • 7
  • 17