Jump to content

[P2] low fps on mobile (circular colliders)


Lotti
 Share

Recommended Posts

Hello! :)

 

I'm a noob about html5 game development and phaser too!

 

I made this sample game / demo http://lotti.github.io/phaserTut and managed to make it run on mobile devices inside chrome and inside cocoonjs "accelerated" canvas view on a nexus 4 where i get 18-21 fps.

 

What am i doing wrong? the game uses p2 physics because i need circle collisions. is there some techniques i can use to get more fps? (You can also answer: you have too many collider/sprite on the screen at the same time :P)

 

Thank you :)

Link to comment
Share on other sites

I know P2 use lots of resources especially o mobile, so I don't know how much is the maximum number of objects you can have.

 

One of the method I would try, is to define a physic on objects which are "related" to the big ball : you don't need to have circle detection collision on every little ball. Just the ones who may collide with the big ball.

 

So I advise you to create a physic body when when the ball is on top of the little balls, and then removing it when the ball is lower. So with that you just have 8 maximum little ball to compute instead of +50.

 

post-5366-0-76643200-1395819017.jpg

 
(PS : I don't have a mouse to do the screenshot, sry :))
Link to comment
Share on other sites

I've searched not deeply but I didn't find a "disable" method as the contrary of 

physics.enable(crow, Phaser.Physics.ARCADE); 

I don't have anymore infos, but in my own code, I used this :

crows.enableBody = true;crows.physicsBodyType = Phaser.Physics.ARCADE;

so maybe try to set to false and to null respectively. I can't test, but that 's what I'd try.

 

If you got smg new don't hesitate.

Link to comment
Share on other sites

First of all: Lotti, did you try to use allowSleep on the body ? Give it a try before trying zaidars workaround.

 

Zaidar, I think your idea is a really good one. I'm currently building a rather complex pinball game with a lot of vertices due to the convex/rounded shape of the inner table and of course all the other involved parts. This project is currently on hold for the mobile platform as it's unplayable.

 

I searched for some workarounds and your solution, which is based on the same idea as you're doing in graphics (removing objects from the scene so they are not rendered at all, so called culling), also came in my mind. Other options I thought of are:

+ Web workers (nearly undoable as I read here http://granular.cs.umu.se/browserphysics/?p=2125, from Steffen, creator of p2)

+ Reduce polygon resolution (not feasible, a curve which his not round is a no-no.

 

The next solution I will try is the mentioned 'physics culling', which should be at least doable, as the game is ball centric like the example above- so you can base all your checks on the location of the ball. I believe this idea is not feasible if you have many to many collisions. I will try to divide my table in different zones and put all objects in that area to sleep.

 

Regards

George

Link to comment
Share on other sites

yes, i already have allowSleep on each dot and each basket too. I was thinking about building a matrix with dots coordinates and enable only dots that are near the ball, as Zaidar said.

 

every basket and every dot are inside a group (one per category). there are some agevolation that can be applied on those groups? (examples: a group-sprite-collider? :P)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...