game on a phone runs faster than in corona simulator

Hello, I am making a minigolf game for android and I have noticed that, the game behaves differently in corona simulator and on a phone.

When I apply same force to a golf ball. The ball travels same distance on both devices, but on a phone it takes significantly more time to travel that distance. For example, It takes 3 second to move the ball from point A to point B in corona simulator and on a phone it takes 5 seconds.

I have no idea why is this happening.

Any suggestions?

Are you including mass in your calculations?

The only right way to apply forces (if you want consistency) is to do this:

-- Create a rectangle local myRect = display.newRect( 0, 0, 100, 100 ) -- Add a body to the rectangle physics.addBody( myRect, "dynamic" ) -- Apply force myRect:applyForce( 50 \* mRect.mass, 200 \* mRect.mass, myRect.x, myRect.y )

If the size of your object changes (perhaps due to scaling choices you made) and you are not accounting for mass, then the responses will not be the same.

Thank you for reply Roaminggamer I have not included mass in my calculations.

So when I did it, it was even slower (on a phone). Then I have changed applyForce() to setLinearVelocity, because I think it is more convinient to use it on striking a golf ball and it helped a little. The game on a phone is not running as smoothly as in corona simulator (like it has small fps).

Here is the code.

 --Add ball ball = display.newCircle( physGroup, start.x, start.y, ballSize ) physics.addBody( ball, "dynamic", { radius=ballSize, bounce=0.7, density = 1} ) ball.myName = "ball" ball.linearDamping = linDamping

ball:applyLinearImpulse( finX \* 0.1 \* ball.mass, finY \* 0.1 \* ball.mass , ball.x, ball.y )

ballSize = 7, linDamping = 1.1, finX and finY varies between -500 and 500

Can you make a little demo that shows the problem?

You can use my askEd Starter as a base, and then add the code you need to main.lua: 

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/askEdStarter.zip

After that, attach it to a post here by 

  1. Clicking ‘More Reply Options’ below.

  2. Then doing this:

attaching_files.jpg

PS - Just so we are clear, first you felt the phone version was running faster, now it is slower?

When I finished the demo, the game started to work just fine. So I figured that it will be because of large amount of physical objects loaded and I have reduced amount of physical object from about 200 to 50. Now the game is running smoothly.

Thank you anyway roaminggamer. :slight_smile:

YW - I suspected this, but wanted you to find it on your own via ‘making a demo of the problem’

Are you including mass in your calculations?

The only right way to apply forces (if you want consistency) is to do this:

-- Create a rectangle local myRect = display.newRect( 0, 0, 100, 100 ) -- Add a body to the rectangle physics.addBody( myRect, "dynamic" ) -- Apply force myRect:applyForce( 50 \* mRect.mass, 200 \* mRect.mass, myRect.x, myRect.y )

If the size of your object changes (perhaps due to scaling choices you made) and you are not accounting for mass, then the responses will not be the same.

Thank you for reply Roaminggamer I have not included mass in my calculations.

So when I did it, it was even slower (on a phone). Then I have changed applyForce() to setLinearVelocity, because I think it is more convinient to use it on striking a golf ball and it helped a little. The game on a phone is not running as smoothly as in corona simulator (like it has small fps).

Here is the code.

 --Add ball ball = display.newCircle( physGroup, start.x, start.y, ballSize ) physics.addBody( ball, "dynamic", { radius=ballSize, bounce=0.7, density = 1} ) ball.myName = "ball" ball.linearDamping = linDamping

ball:applyLinearImpulse( finX \* 0.1 \* ball.mass, finY \* 0.1 \* ball.mass , ball.x, ball.y )

ballSize = 7, linDamping = 1.1, finX and finY varies between -500 and 500

Can you make a little demo that shows the problem?

You can use my askEd Starter as a base, and then add the code you need to main.lua: 

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/askEdStarter.zip

After that, attach it to a post here by 

  1. Clicking ‘More Reply Options’ below.

  2. Then doing this:

attaching_files.jpg

PS - Just so we are clear, first you felt the phone version was running faster, now it is slower?

When I finished the demo, the game started to work just fine. So I figured that it will be because of large amount of physical objects loaded and I have reduced amount of physical object from about 200 to 50. Now the game is running smoothly.

Thank you anyway roaminggamer. :slight_smile:

YW - I suspected this, but wanted you to find it on your own via ‘making a demo of the problem’