Confusion with linear velocity

I’ve got a simple little proof-of-concept where there’s an image that starts in the middle of the screen, and I set it moving in a given direction.  I can make it go up, down, and right, but I cannot get it to start moving to the left.  If it moves to the right and bounces off of the wall, it heads back to the left, so I know it can work, but I cannot figure out what the problem is!

I’ve tried setLinearVelocity and applyLinearImpulse, and the results are the same - no initial movement to the left.

There’s no gravity in the scene, either.

newInstance:setLinearVelocity( 0, -128) -- moves up newInstance:setLinearVelocity( 0, 128) -- moves down newInstance:setLinearVelocity( 128, -128) -- moves diagonally up and right newInstance:setLinearVelocity( 128, 128) -- moves diagonally down and right newInstance:setLinearVelocity( 128, 0) -- moves right newInstance:setLinearVelocity(-128, 0) -- WON'T MOVE LEFT!!!!

Help! and Thanks!

I’ve just tried this

local physics = require("physics") physics.start() physics.setGravity(0,0) local bob = display.newCircle(display.contentWidth/2, display.contentHeight/2, 30) physics.addBody(bob, "dynamic") bob:setLinearVelocity(-128,0)

in a blank project and it works fine.

are there any messages showing up in your console?

Thanks for trying it out.  I did the same thing, and it worked fine too.  Obviously it is something that I am doing.

I left off a lot of detail about my app because I didn’t think it was relevant.  I shouldn’t have done that.  I load a Tiled Map through Ponytiled, and I scale it to fit the screen width.  I’ve read you shouldn’t scale physics objects, but all of the other physics aspects seem to work.  I tried my experiment without scaling the map, and now it moves to the left.  I had problems before with touching the scaled map, because the coordinates were off.  I put in a call to contentToLocal to get the translated coordinates, and passed the results into applyLinearImpulse.  And now, my object moves to the left on start!

Thanks for getting me to think a little bit more about how I could be causing the problem!

I’ve just tried this

local physics = require("physics") physics.start() physics.setGravity(0,0) local bob = display.newCircle(display.contentWidth/2, display.contentHeight/2, 30) physics.addBody(bob, "dynamic") bob:setLinearVelocity(-128,0)

in a blank project and it works fine.

are there any messages showing up in your console?

Thanks for trying it out.  I did the same thing, and it worked fine too.  Obviously it is something that I am doing.

I left off a lot of detail about my app because I didn’t think it was relevant.  I shouldn’t have done that.  I load a Tiled Map through Ponytiled, and I scale it to fit the screen width.  I’ve read you shouldn’t scale physics objects, but all of the other physics aspects seem to work.  I tried my experiment without scaling the map, and now it moves to the left.  I had problems before with touching the scaled map, because the coordinates were off.  I put in a call to contentToLocal to get the translated coordinates, and passed the results into applyLinearImpulse.  And now, my object moves to the left on start!

Thanks for getting me to think a little bit more about how I could be causing the problem!