Hierarchical per-node time scaling #132

wants to merge 763 commits into


None yet
lhunath commented Dec 19, 2011

This allows you to specify a time scale on a node in the scene, which causes all actions and schedules on it and all its children to get scaled in time. This is vital to slow down certain parts of a scene; eg. all the game but not the menus.

lhunath commented Dec 19, 2011

You probably don't want to apply 711da56


Interesting approach. Have you done any performance tests? How much does it affect the runtime.

For cocos2d v2.0 it is also possible to alter the speed of a tree of nodes by using multiple schedulers and/or action managers. I will create an example soon.

lhunath commented Dec 22, 2011

I haven't; but I don't expect the cost to be high, especially when the developer isn't using it explicitly. Then it's just the cost of respondsToSelector:. Worth testing, but I can't make any time for it lately, I'm afraid.

ricardoquesada and others added some commits Jan 4, 2012
@ricardoquesada ricardoquesada updated CHANGELOG 6a1886f
@ricardoquesada ricardoquesada Templates: better names bcf4659
@ricardoquesada ricardoquesada TMX: if using AntiDiagonally flip, crash 0cd4e2a
@ricardoquesada ricardoquesada Oops... missing templates 6ea198b
@ricardoquesada ricardoquesada ActionsProgress added to Mac b35179e
@ricardoquesada ricardoquesada MotionStreak added to Mac ddd0f7d
@ricardoquesada ricardoquesada Tests: Added NodeTest, LayerTest, RotateWorldTest and SceneTest to Ma…
…c project
@ricardoquesada ricardoquesada Transition update:
CCTrasitionRadial... renamed to CCTransitionProgressRadial...

Added 4 new transitions:
    CCTransitionProgressHorizontal, CCTransitionProgressVertical,
    CCTransitionProgressInOut and CCTransitionProgressOutIn
@ricardoquesada ricardoquesada Templates: Using new renamed file: CCTransitionRadial.x 793f36c
@ricardoquesada ricardoquesada EventDispatcher and TouchDispatcher are "part" of CCDirector and not …
…of its subclasses
@ricardoquesada ricardoquesada Effects & Transitions: 2d effects and transitions work as expected wi…
…th a 2d Projection
@ricardoquesada ricardoquesada Updated README 3187903
@ricardoquesada ricardoquesada small fix on download link 10ebd4b
@ricardoquesada ricardoquesada Using Chipmunk v6.0.3 0429fc4
@ricardoquesada ricardoquesada Removed extras directory c21a625
@ricardoquesada ricardoquesada PerformanceTests compiles and run with v2.0b2 25b7a3a
@ricardoquesada ricardoquesada RetinaDisplay on performance tests f14c25d
@ricardoquesada ricardoquesada Events-Mac: Fixes crash when removing event delegate within an event 420c201
@ricardoquesada ricardoquesada GLProgram renamed to CCGLProgram 878ccd1
@ricardoquesada ricardoquesada Important API changes
GLProgram -> CCGLProgram
EAGLView -> CCGLView
MacView -> CCGLView
MacWindow -> CCWindow
ESRenderer -> CCESRenderer
ES2Renderer -> CCES2Renderer
@ricardoquesada ricardoquesada Grid: Mac 64-bit Grid3D allocates only the needed memory 044ff40
@ricardoquesada ricardoquesada Removed Xcode4_template reference from project 6569217
@ricardoquesada ricardoquesada PerfromanceTest: updated to use new cocos2d files d2e3268
@ricardoquesada ricardoquesada Merge branch 'gles20' of github.com:cocos2d/cocos2d-iphone into gles20 1d3e8eb
@ricardoquesada ricardoquesada Box2d templates use CCGLProgram 4427f05
@ricardoquesada ricardoquesada Effects: Works again in RetinaDisplay 3061539
@ricardoquesada ricardoquesada Shaders: example shaders use the example_ prefix 347ef24
@ricardoquesada ricardoquesada EAGLView -> CCGLView in unused code dfeac16
@ricardoquesada ricardoquesada MacDirector: eventDispatcher is a property b6f2881
@ricardoquesada ricardoquesada Templates Shaders: added missing AlphaTest shader. Removed example_ s…
@ricardoquesada ricardoquesada Updated README: 10.5 is no longer supported 863e0b1
@ricardoquesada ricardoquesada ARC: fixed compile error when using macro in ARC 2f965ff
@ricardoquesada ricardoquesada Doxygen fixes d031d36
@ricardoquesada ricardoquesada Little fix on README: Leopard -> Snow Leopard 1d902c4
@ricardoquesada ricardoquesada Fixed memory leak in particle#fillWithEmptyQuadsFromIndex 0cb8ae3
@ricardoquesada ricardoquesada FontSize and FontName are properties of LabelTTF 196512a
@ricardoquesada ricardoquesada Adds setFntFile to LabelBMFont dc48556
@ricardoquesada ricardoquesada SpriteBatch: Quad extensions are public. Moved from TMXMap.m to Sprit…
@ricardoquesada ricardoquesada Texture2D: initWithImage -> initWithCGImage 741b77b
@ricardoquesada ricardoquesada Compiles on Mac d2f9d23
@slycrel slycrel Fix to tile maps with multiple tile sets that have rotation
Fixed a problem with multiple layers and multiple tile sets that could
cause TMX maps to not load if rotation is used.
Fixed a theoretical problem with tile bounds checking.


@ricardoquesada ricardoquesada Updated AUTHORS 3802b0f
@ricardoquesada ricardoquesada Merge remote-tracking branch 'origin/develop' into gles20
@ricardoquesada ricardoquesada DrawColor4F uses Floats instead of bytes. Issue #1307 6e7e142
@ricardoquesada ricardoquesada Merge branch 'develop' into gles20
@ricardoquesada ricardoquesada Added new animation format
Supports "delays" per frame.
Not fully tested
@ricardoquesada ricardoquesada SpriteFrame: copyWithZone works as expected. Fixed memory leak in CCA…
@ricardoquesada ricardoquesada Fixed memory leak in CCAnimationCache 042d885
@ricardoquesada ricardoquesada Improved API for the new animation format 3765020
@ricardoquesada ricardoquesada Fixes issue #1312 1a72e18
@ricardoquesada ricardoquesada use ` instead of ' in README.md dfdb8f7
@ricardoquesada ricardoquesada Merge branch 'develop' into gles20
@ricardoquesada ricardoquesada test 78a0f19
@ricardoquesada ricardoquesada revert test test 2cd793b
@ricardoquesada ricardoquesada Update README.md 8c4e9be
@ricardoquesada ricardoquesada Merge branch 'gles20' of github.com:cocos2d/cocos2d-iphone into gles20 578bae8
@ricardoquesada ricardoquesada Merge branch 'develop' into gles20
@ricardoquesada ricardoquesada Merge branch 'develop' into gles20 f18e019
@ricardoquesada ricardoquesada Merge branch 'develop' into gles20 1fda368
@ricardoquesada ricardoquesada Fixes issue #1217 cb5df64
@ricardoquesada ricardoquesada updated CHANGELOG 3b99766
@ricardoquesada ricardoquesada PerformanceTest compiles 1358dea
@ricardoquesada ricardoquesada fixes issue #1311 59dcd3f
@ricardoquesada ricardoquesada New Animation format:
removed Offset
added notifications
@ricardoquesada ricardoquesada TextureAtlas: added option to not use VAO 6f7eb07
@ricardoquesada ricardoquesada Sprite: only update texture if it is different than the original 2b36d6c
@ricardoquesada ricardoquesada Director: display number of GL draw calls per frame when stats are en…
@ricardoquesada ricardoquesada updated schema for Xcode in box2d test 8cdf498
@ricardoquesada ricardoquesada VAO should be enabled 7638061
@ricardoquesada ricardoquesada Performance tests use RGB5 and no depth buffer (as in v1.0) 01d79cf
@ricardoquesada ricardoquesada if the string is the same, don't update it. bcc39d6
@ricardoquesada ricardoquesada update the Seconds per Frame only when the FPS is updated 3d6193f
@ricardoquesada ricardoquesada Mac: If no OpenGL context, don't render it 577dced
@ricardoquesada ricardoquesada Added example of custom TTF in Mac 4ee832b
@ricardoquesada ricardoquesada Updated CHANGELOG 5bc2ebf
@ricardoquesada ricardoquesada CCSprite:setDisplayFrameWithAnimationName works with the new animatio…
…n system
@ricardoquesada ricardoquesada Mac View: missing [glContext makeCurrent] // causing crashes ? b187cf4
@ricardoquesada ricardoquesada MacView: resize bug fixed again 6712473
@ricardoquesada ricardoquesada GLProgram: reports error correctly on vertex shaders 3b31cc4
@ricardoquesada ricardoquesada fixes issue #1315 . MSAA working again on iOS 7ebfd8d
@ricardoquesada ricardoquesada Added Memory Test 8c0ef07
@ricardoquesada ricardoquesada Merge branch 'develop' into gles20
@ricardoquesada ricardoquesada Fixed v1.1 particle test where particles are added / removed 0ff8067
@ricardoquesada ricardoquesada Updated chagenlog e6aae3a
@ricardoquesada ricardoquesada Menu: added support for init/create with NSArray 4cff6d8
@ricardoquesada ricardoquesada Many menu improvements:
Menu could be created without items
Menu could be enabled/disabled (no events will be accepted when it is disabled)
It is possible to change its priority on runtime
kCCMenuTouchPriority -> kCCMenuHandlerPriority
@ricardoquesada ricardoquesada Improved FPS_images file 1bce3be
@ricardoquesada ricardoquesada updates samples that use fps_images.png 3dc18f0

To be honest, previous one looked better for me. But anyway, this new font has some ghosts for space character I think. You tested only on black background so you can't see, try some brighter backgrounds and watch especially before number of GL draw calls...


Actually, even this test case proves fix is not good. If you inspect grossini moves, you'll see he always ends in slightly different position. Just compare his legs position to the green left arrow. But I don't think CCRepeat bug is completely responsible for this behavior, even if you run this act3 only once, grossini will not have same ending position. Also use this test case for checking the fix: 9f70fd1#commitcomment-994129

ricardoquesada and others added some commits Feb 22, 2012
@ricardoquesada ricardoquesada Fixes issue #1288. Repeat one time works as expected 1d5a87a
@ricardoquesada ricardoquesada fixes issue #1284 01f7263
@ricardoquesada ricardoquesada CC_DIRECTOR_INIT doesn't call enable retinaDisplay by default 1fd8223
@ricardoquesada ricardoquesada fixes issue #1324
Added KVO for Director#isPaused
@ricardoquesada ricardoquesada Add another GlyphDesigner test bb6199d
@ricardoquesada ricardoquesada Texture2DTest: Don't enable RetinaDisplay fffd546
@ricardoquesada ricardoquesada LabelBMFont: code easier to read. 876acb3
@ricardoquesada ricardoquesada Updated CHANGELOG with issue numbers 55e2a5c
@ricardoquesada ricardoquesada fixes issue #762
BMLabelFont supports "image offset" in order to share the texture with other images.
@ricardoquesada ricardoquesada updated BMlabelFont docstrings with more editors be5c661
@ricardoquesada ricardoquesada fixes issue #770
CCLabelBMFont supports any unicode character.
Added test for it.
@ricardoquesada ricardoquesada LabelBMFont: takes less memory 2638181
@ricardoquesada ricardoquesada Issue #886 re-fixed. Added support for RGB888 on "default pixel forma…
…t" as well
@ricardoquesada ricardoquesada Added test case for another aciton bug b09644d
@ricardoquesada ricardoquesada Sequence bug fixed 3419a40
Viktor Lidholt Added support for growing the total number of particles in CCParticle…
@Panajev Panajev (x): fixes documentation issue with CCSpeed. 799a130
@ricardoquesada ricardoquesada Merge pull request #173 from Panajev/gles20
@ricardoquesada ricardoquesada renamed issueXXX to issue1327 46cf93c
@ricardoquesada ricardoquesada Merge branch 'gles20' of github.com:cocos2d/cocos2d-iphone into gles20 8dea3ac
@ricardoquesada ricardoquesada Animation: deprecated animationWithFrame... use animationWithSpriteFr…
…ame instead
@ricardoquesada ricardoquesada Animation: added support for loops
Also deprecated some confusing methods on Animation/Animate
@ricardoquesada ricardoquesada Added kCCLabelAutomaticWidth enum. Replaced -1 on width 7fa9eba
@ricardoquesada ricardoquesada dimension is a property on LabelTTF 302dd76
Viktor Lidholt Made improvements to CCParticleSystem and added spriteFrame setters f…
…or CCMenuItemImage
Viktor Lidholt Merge branch 'gles20' of github-ca.corp.zynga.com:externals/cocos2d-i…
…phone into gles20

@ricardoquesada ricardoquesada Added -merge too to .gitattributes a6ca983
Viktor Lidholt Made CCNode zOrder a writeable property 215ea55
@ricardoquesada ricardoquesada Merge remote-tracking branch 'vlidholt/particleimprovements' into gles20
@ricardoquesada ricardoquesada Merge remote-tracking branch 'vlidholt/nodeimprovements' into gles20
@ricardoquesada ricardoquesada RenderTexture: Locks OpenGL context before calling any OpenGL command d92cdff
@ricardoquesada ricardoquesada Texture & TextureCache: uses current thread and cocos2d thread
Texture2D: uses current thread for glDeleteTexture()
TextureCache: uses cocos2d thread to invoke async callback()

These bugs were causing kernel panics on Mac
@ricardoquesada ricardoquesada RenderTexture: saves image in correct path 5861a85
@ricardoquesada ricardoquesada Templates: fixes memory leaks on templates 4db5d5c
@ricardoquesada ricardoquesada Templates: added NSThread+performBlock 0b291c6
@ricardoquesada ricardoquesada Templates: added missing files and added -all_load -Objc on OTHER_LIN…
@ricardoquesada ricardoquesada Added more deprecated methods and enums in ccDeprecated 9e14bb2
@ricardoquesada ricardoquesada fixes memory leak on DirectorTes 24658bb
@ricardoquesada ricardoquesada remove "-all_load" from OTHER_LINKER_FLAGS
Apparently it is not needed, only -ObjC is needed

Further info: https://developer.apple.com/library/mac/#qa/qa1490/_index.html
@ricardoquesada ricardoquesada Fixes memory warning reported by static analyzer 9c5735b
@ricardoquesada ricardoquesada Added retro test 0d98834
@ricardoquesada ricardoquesada RetroEffect with scale 0a68097
@ricardoquesada ricardoquesada Retro effect: with negative scaling b19932d
@ricardoquesada ricardoquesada schemes optimized for Xcode 4.3
schemes uses LLDB as default debugger.
Changes made automatically by Xcode 4.3
@ricardoquesada ricardoquesada tests: removed duplicated entries 41f780f
@ricardoquesada ricardoquesada basetest supports retina disabled de07a54
@ricardoquesada ricardoquesada Test: shader works on iOS 4.3 using lowp 76c34bc
@ricardoquesada ricardoquesada install-template: removed -u option
Since -u option was not used, it was removed
@ricardoquesada ricardoquesada RenderTexture: Don't force the cocos2d's opengl context
Since it should be possible to use RenderTexture from another thread, it is not forced the use of cocos2d's main thread opengl context
@ricardoquesada ricardoquesada RetinaDisplay disabled on shaders dcc5631
@ricardoquesada ricardoquesada Added -ipadhd support on iPad Retina Display 9217089
@ricardoquesada ricardoquesada Added -ipadhd support on iPad Retina Display 84d7edd
@ricardoquesada ricardoquesada Merge branch 'gles20' of github.com:cocos2d/cocos2d-iphone into gles20 d11b0e1

There are few inconsistencies in comments regarding iPad retina suffix. I believe default is "-ipadhd" but on few locations you stated default is "-ipad-hd"


thanks. fixed.


Here too and all other files below...


Here you're missing this code:

if( ! ret ) {
    *resolutionType = kCCResolutioniPhone;
    ret = fullpath;

I suppose you mistakenly deleted lines 174-176? Without this piece of code CCFileUtils returns nil for valid files without "-hd" extension for example...


thanks. fixed.


Hey guys. Any chance to get this fix merged into 1.x as well?

ricardoquesada and others added some commits Mar 13, 2012
@ricardoquesada ricardoquesada Performance tests compile and run with v2.0-rc0 a182272
@ricardoquesada ricardoquesada Test Xcode project: Updated schemes to use lldb 1b33596
@ricardoquesada ricardoquesada Tests: Shaders tests works 75e4ea3
@ricardoquesada ricardoquesada revert doxygen changes 770b86c
@lhunath lhunath Use correct type for action in ActionInterval users. e2bdd40
@lhunath lhunath Hierarchical slow-motion support.
Without this patch it's impossible to apply slow-motion to a whole
subset of your scene hierarchy without having to manually apply ccspeed
actions to each of the hierarchy's actions and trying to keep it updated
when you want to activate the slow-motion.


@lhunath lhunath Fix: don't use depth testing when no depth buffer will be used. ac08149
@lhunath lhunath Rename speed to timeScale to avoid ambiguity with other nodes that al…
…ready have a 'speed'. Also add support for node-schedules.


@ricardoquesada ricardoquesada CCFileUtils: many improvements
Added support for fallback suffixes
It is an singleton (easier to subclass)
NSBundle and NSfileManager are properties (easier to customize)


@ricardoquesada ricardoquesada CCFileUtils: Adds a cache to remove/obtain path to improve the speed a21a028
@ricardoquesada ricardoquesada Director: purge CCFileUtils cache if FPSLabels are going to be recreated 1a84ac6
@ricardoquesada ricardoquesada fixes issue #1344
FileUtils returns a valid path even if the no-suffix file is not present.


@ricardoquesada ricardoquesada Improved tests for iPad

@ricardoquesada ricardoquesada CCFiletutils: remove suffix supports "fallback" for removing suffixes 95ef8d7
Viktor Lidholt Better support for custom fonts in CCLabelTTF for Mac and added align…
…ment property.
Viktor Lidholt Fixed LabelTTF, according to comments. 16d868f
Viktor Lidholt Fixed compile issue in iOS 274d313
@ricardoquesada ricardoquesada fixed compiler warning 0d44739
@lhunath lhunath Fix depth test toggle to cocos2d 2.0 API. 93f7ca7
lhunath commented Apr 9, 2012

I fail to see how a CCTargetedAction could affect all actions and schedules previously applied to a tree of nodes.

lhunath commented Apr 9, 2012

Given that action managers manage time for a target, I think it's acceptable that it also manages the scaling of that time allocation. I wouldn't call that bloat.

I haven't tried the multiple schedulers/action managers approach yet, I don't know what it would involve, but ideally, it shouldn't require all nodes in a tree or all actions and schedules applied to them to perform some special logic such as wrapping actions or assigning special managers to each node in the tree.

@lhunath lhunath More permissive texture clamping check and assert that a shader progr…
…am is set during CCNode's draw setup.

-[CCTexture2D setTexParameters:] currently asserts that textures are
either POT or use clamping.  This is too restrictive and doesn't permit
things like REPEAT on POT dimensions while the other dimension isn't

CC_NODE_DRAW_SETUP() enables the node's shader program.  Usage of this
macro indicates that the node is about to draw something.  This draw
operation requires that a shader program is set on the node, otherwise
the resulting draw operation is undefined (it's indetermined which
shader program will be used for it).  Therefore, it's safe to assume
that no shader program being set on the node is a bug and we can assert
during the function that a shader program is actually set to catch these
bugs fast.
araker commented Apr 10, 2012

Using CCTargetedAction would mean flatten the tree, wrap all actions in a CCTargetedAction and put them in a sequence/spawn which is wrapped in a CCSpeed. Changing the rate of the speed action would then give the same result. I have to admit, it's certainly not as convenient as your code.

Using a seperate manager for a certain hierarchy of nodes would be a interesting approach as well.


This change will lead to another issue! Plz see http://www.cocos2d-x.org/boards/6/topics/11708

@Birkemose Birkemose closed this Mar 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment