Physics not working as expected.

I’m trying to add physics to a cube so that it falls down and has an animation to it, but instead of falling it keeps floating to the left.

local sheetOptions =

{

    width = 97,

    height = 99,

    numFrames = 2

}

local sheet_rollingCube = graphics.newImageSheet( “Cube.png”, sheetOptions )

local sequences_rollingCube = {

    {

        name = “fastRoll”,

        frames = { 1,2},

        time = 400,

        loopCount = 0,

        loopDirection = “forward”

    }

}

local rollingCube = display.newSprite( sheet_rollingCube, sequences_rollingCube)

rollingCube.x = display.screenOriginX +60

rollingCube.y = display.screenOriginY +400

physics.addBody( rollingCube, “dynamic” )

rollingCube:scale( -0.5, -0.5 )

It sounds like you don’t have gravity set up properly or you are applying some other forces to the object. Try setting “physics.setGravity( 0, 6 )” and see if the object falls then.

https://docs.coronalabs.com/api/library/physics/setGravity.html

I tried it still doesn’t work.

Open your simulator. Select “New Project” and choose “Physics Based Game” as your project template. Press OK and Corona will create you a simple app where a box drops to the ground. You’ll find the code for the scene in “level1.lua”.

Do that, and you’ll find out what your mistake is.

*Edit: Alternative, just copy the Example code from https://docs.coronalabs.com/api/library/physics/setGravity.html. It’ll also work.

It sounds like you don’t have gravity set up properly or you are applying some other forces to the object. Try setting “physics.setGravity( 0, 6 )” and see if the object falls then.

https://docs.coronalabs.com/api/library/physics/setGravity.html

I tried it still doesn’t work.

Open your simulator. Select “New Project” and choose “Physics Based Game” as your project template. Press OK and Corona will create you a simple app where a box drops to the ground. You’ll find the code for the scene in “level1.lua”.

Do that, and you’ll find out what your mistake is.

*Edit: Alternative, just copy the Example code from https://docs.coronalabs.com/api/library/physics/setGravity.html. It’ll also work.