Comments (4)
After lowering the map size and removing trees, the game ran smoothly, which led me to believe that there was a graphics memory problem. I tested in Instruments and under 12 megabytes of memory were being used, but always over 50% of the CPU was in use. I'm not sure how to fix this.
from sparrow-vs.-cocos.
One thing that always helps when touch events slow the game down is to set all objects that don't need to be touched to "touchable = NO". This does not have to be done with all leaf objects (images, quads), but it suffices (and is even better) to deactivate it as far up in the display tree as possible: in the topmost sprites containing them. When a sprite is untouchable, Sparrow does not have to check its children for touches and can ignore them completely. When there are many objects, this can make a huge difference.
Perhaps this helps!
from sparrow-vs.-cocos.
Something I found to also be a big drag on performance is calling self.width or self.height on Sparrow display objects in tight loops. This appears to call a bunch of code behind that (rather than returning a value right away) and can be a major bottleneck if you're not careful. Replacing it with cached values for those improved framerates on our stuff by 3-4x. Profiling can sniff these kinds of things out.
from sparrow-vs.-cocos.
Thanks jon914, you're perfectly right -- it's always a good tip to cache those values when you need them repeatedly. When you've got a complex sprite, calculating the bounds (that is, width & height) is an expensive operation.
from sparrow-vs.-cocos.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sparrow-vs.-cocos.