SlideShare a Scribd company logo
cocos2d performance tips
1.
        nonatomic               !!




@property(nonatomic,assign) float altitude;
2.                         NSMutableArray
 NSArray                  CCArray




                          enumerator

     for ( CellObject *object in objects ) {
       ...
     }
cocos2d          ( 0.9.x   )
CC_ARRAY_FOREACH

CellObject *object;
CC_ARRAY_FOREACH(objects,object) {
  ...
}
for

for ( int i = 0;i < self.numObjects; i++ ) {
... hoge[i]
}

           indexOfObject
3.




     float




            count   length
4. float       double



          float     32bit
     double      64bit
                   100
5.




break
6.           tips




2   (x1,y1),(x2,y2)
float xd = endpoint.x - startpoint.x;
float yd = endpoint.y - endpoint.y;
float comparedist = 100 * 100;
distance = xd * xd + yd * yd;

if (distance > comparedist) {
...
}
sqrt
http://en.wikipedia.org/wiki/Fast_inverse_square_root


            float fast_sqrt(float number) {
            	

 	

 long i;
            	

 	

 float x, y;
            	

 	

 const float f = 1.5f;

            	

   	

   x = number * 0.5f;
            	

   	

   y = number;
            	

   	

   i = *(long*) &y;
            	

   	

   i = 0x5f3759df - ( i >> 1 );
            	

   	

   y = *(float*) &i;
            	

   	

   y = y * ( f - ( x * y * y ) );
            	

   	

   y = y * ( f - ( x * y * y ) );
            	

   	

   return number * y;
            }
http://iphonedevelopment.blogspot.com/2009/03/speed-with-
                       catch.html

 iPhone   InvSqrt


                                   Normalize
7.
RELEASE
Challenge optimizing your code!!

More Related Content

PDF
Flashback, el primer malware masivo de sistemas Mac
PDF
Bartosz Milewski, “Re-discovering Monads in C++”
PDF
LLVM Backend の紹介
PDF
Arduino coding class
PDF
Arduino coding class part ii
PDF
JavaScript - Agora nervoso
PDF
20170127 tokyoserversideswiftmeetup資料
PDF
Chainer-Compiler 動かしてみた
Flashback, el primer malware masivo de sistemas Mac
Bartosz Milewski, “Re-discovering Monads in C++”
LLVM Backend の紹介
Arduino coding class
Arduino coding class part ii
JavaScript - Agora nervoso
20170127 tokyoserversideswiftmeetup資料
Chainer-Compiler 動かしてみた

What's hot (20)

TXT
Senior design project code for PPG
PDF
Lambda expressions in C++
PDF
Let’s talk about microbenchmarking
PDF
TMPA-2017: Predicate Abstraction Based Configurable Method for Data Race Dete...
PPTX
Egor Bogatov - .NET Core intrinsics and other micro-optimizations
PDF
Vc4c development of opencl compiler for videocore4
PPTX
PPTX
How to add an optimization for C# to RyuJIT
PDF
SFO15-500: VIXL
PDF
Stage3D and AGAL
PDF
Writing SOLID C++ [gbgcpp meetup @ Zenseact]
PDF
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
PDF
MATHS SYMBOLS - #2 - EXPONENTIALS and LOGARITHMS
PDF
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
PDF
Java, Up to Date Sources
PPTX
Box2D with SIMD in JavaScript
PAGES
Unix open
KEY
IonMonkey Mozilla All-Hands 2011
PDF
The Big Three
Senior design project code for PPG
Lambda expressions in C++
Let’s talk about microbenchmarking
TMPA-2017: Predicate Abstraction Based Configurable Method for Data Race Dete...
Egor Bogatov - .NET Core intrinsics and other micro-optimizations
Vc4c development of opencl compiler for videocore4
How to add an optimization for C# to RyuJIT
SFO15-500: VIXL
Stage3D and AGAL
Writing SOLID C++ [gbgcpp meetup @ Zenseact]
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
MATHS SYMBOLS - #2 - EXPONENTIALS and LOGARITHMS
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
Java, Up to Date Sources
Box2D with SIMD in JavaScript
Unix open
IonMonkey Mozilla All-Hands 2011
The Big Three
Ad

Viewers also liked (10)

KEY
Photobook
KEY
TiPhotobook_en
KEY
CCSendMessages introduction
PDF
iOS app hacks
KEY
Cocos2d platforms
PDF
apportable meeting
PDF
iOS app hacks all_map
PDF
Gcs2014 0225 cocos2d-xjsb
PDF
Advanced cocos2d
PDF
Androidアプリで日商100万円達成した時にやったこと
Photobook
TiPhotobook_en
CCSendMessages introduction
iOS app hacks
Cocos2d platforms
apportable meeting
iOS app hacks all_map
Gcs2014 0225 cocos2d-xjsb
Advanced cocos2d
Androidアプリで日商100万円達成した時にやったこと
Ad

Similar to Cocos2d Performance Tips (20)

DOCX
2.1 ### uVision Project, (C) Keil Software .docx
DOCX
COMPAPPABCA49085rFunrAP__Practical Number 9 & 10.docx
PDF
Marat-Slides
PDF
Write Python for Speed
PDF
Boosting Developer Productivity with Clang
PDF
PDF
C Code and the Art of Obfuscation
PDF
All I know about rsc.io/c2go
PPTX
Chapter 7 functions (c)
PDF
Coscup2021 - useful abstractions at rust and it's practical usage
PDF
Rust: код может быть одновременно безопасным и быстрым, Степан Кольцов
PPTX
Codestrong 2012 breakout session hacking titanium
PDF
CUDA Deep Dive
PPTX
Node.js System: The Landing
PDF
Automatically Describing Program Structure and Behavior (PhD Defense)
PDF
Improving Android Performance at Droidcon UK 2014
PPT
为什么 rust-lang 吸引我?
PPTX
The State of JavaScript (2015)
PDF
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
2.1 ### uVision Project, (C) Keil Software .docx
COMPAPPABCA49085rFunrAP__Practical Number 9 & 10.docx
Marat-Slides
Write Python for Speed
Boosting Developer Productivity with Clang
C Code and the Art of Obfuscation
All I know about rsc.io/c2go
Chapter 7 functions (c)
Coscup2021 - useful abstractions at rust and it's practical usage
Rust: код может быть одновременно безопасным и быстрым, Степан Кольцов
Codestrong 2012 breakout session hacking titanium
CUDA Deep Dive
Node.js System: The Landing
Automatically Describing Program Structure and Behavior (PhD Defense)
Improving Android Performance at Droidcon UK 2014
为什么 rust-lang 吸引我?
The State of JavaScript (2015)
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)

More from Keisuke Hata (13)

KEY
CCResourceAsyncLoader
PDF
Impact beginngers guide_1.19
KEY
Introduction titanium
PDF
Hello cocos2d ios
PDF
Hello cocos2d ios
KEY
Google wave2010
KEY
How To Build Last Fm For I Phone
PDF
Mercurial&OnenoteServer
PDF
Math1 Vector
PDF
Wiipen
PDF
Gl Rotate
PDF
Gl Matrix
PDF
Are You Enjoy Ruby 1 Day
CCResourceAsyncLoader
Impact beginngers guide_1.19
Introduction titanium
Hello cocos2d ios
Hello cocos2d ios
Google wave2010
How To Build Last Fm For I Phone
Mercurial&OnenoteServer
Math1 Vector
Wiipen
Gl Rotate
Gl Matrix
Are You Enjoy Ruby 1 Day

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
A Presentation on Artificial Intelligence
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Empathic Computing: Creating Shared Understanding
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Big Data Technologies - Introduction.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
sap open course for s4hana steps from ECC to s4
A Presentation on Artificial Intelligence
MIND Revenue Release Quarter 2 2025 Press Release
Empathic Computing: Creating Shared Understanding
Assigned Numbers - 2025 - Bluetooth® Document
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
“AI and Expert System Decision Support & Business Intelligence Systems”
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
20250228 LYD VKU AI Blended-Learning.pptx
The AUB Centre for AI in Media Proposal.docx
Dropbox Q2 2025 Financial Results & Investor Presentation
Big Data Technologies - Introduction.pptx
Spectral efficient network and resource selection model in 5G networks
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Programs and apps: productivity, graphics, security and other tools
Advanced methodologies resolving dimensionality complications for autism neur...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf

Cocos2d Performance Tips

Editor's Notes