Problem with physics only happening in Android devices (Part2) (Solved)

I’m still having problems with built in physics using cocos2dx-17.2 only on Android devices.

I had to cancel this minigame for Halloween because is really unplayable.

Here is the intended and normal behavior in iOS devices:

And here is the wrong behavior in Android devices:

What should I do? Any thoughts?

Nice game port, but physics behavior is very ugly on android.
Without any example code I can not help.
Can you make a small example which have the same behavior?
No sprites! No effect. Only a small example which works in debug mode.

I have rebuild the demo:
PhysicsEditor-Cocos2d-x

And get also an mystery behavior on Windows OS.
Can you build it on android and IOS?
Tell whats happens.

Thank you, really appreciate it.

I finished the demo. Basically I’m using the same code you posted.

I didn’t check it on Windows OS but it seems that it only works well on iOS ?¿

@panor I think autostep is the issue, but it should be turn off after scene is initialized.
I used physics in so many games without any problem.
Try below, i hope this will help you.

// In init() or constructor
this->scheduleOnce(SEL_SCHEDULE(&TerryTowers::updateAutoStep), 0.1f);
...

void TerryTowers::updateAutoStep(float dt)
{
	this->getScene()->getPhysicsWorld()->setAutoStep(false);
	this->schedule(SEL_SCHEDULE(&TerryTowers::updateGame));
}

void TerryTowers::updateGame(float dt) 
{
	this->getScene()->getPhysicsWorld()->step(1.0f / 60.0f);
}
3 Likes

It works now, thank you!!
I tried something like this as you probably saw in my code but as I was turning off before the scene was created it didn’t work.

Thanks again!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.