Cocos2dx - setVelocity works differently on other devices with same resolution
Asked Answered
O

0

0

I'm dying with physics , i've tried to use setVelocity however i got slightly different result from different devices.

I've tested on iPhone 5 (on simulator) and iPhone 6 (real device) The Director::getInstance()->getOpenGLView()->getFrameSize() returns both devices is 640x1136 pixels

But i see they have different result after the animation , its about 2-5 pixels. I really don't know why.

I'm making a multiple player game so i need exactly same coordinate of objects on every devices. Does cocos physics return randomly result?

Oppugnant answered 2/10, 2016 at 10:8 Comment(2)
cocos2d-x use Chipmunk physics engine so as author of this engine says you can run simulations on your server and then synchronize it with clients. So physics would run only on server.Trocar
if you are new to real time multiplayer games i think Multiplayer Game Programming: Architecting Networked Games (Game Design) 1st Edition can be useful. And yes Chipmunk Physics engine will produce slightly different results on different devices. So I would suggest you to run physics simulation only on the server and then just showing results on the players screens. Also for realtime game decide to use UDP sockets or framework on top of UDP. You can use TCP connection only for games like chess or pokerTrocar

© 2022 - 2024 — McMap. All rights reserved.