Export to GitHub

cocos2d-iphone - issue #173

Layer and scene cannot change their opacity


Posted on Jan 29, 2009 by Massive Bird

What steps will reproduce the problem? 1. Make a layer 2. try to apply FadeTo action to it 3.

What is the expected output? What do you see instead? All objects inside a layer change their opacity. Instead of that exception is generated: 009-01-29 14:56:41.907 HandyChess[1986:20b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[MainMenuMenu opacity]: unrecognized selector sent to instance 0x107a010'

What cocos2d version are you using ? 0.6.2

Please provide any additional information below.

I beleive that layer opacity can be expressed as changing opacity all the child nodes (for those nodes that understand this method).

It is very inconvenient that opacity should be applied to individual nodes but cannot be applied to a layer itself.

Comment #1

Posted on Jan 29, 2009 by Massive Bird

It is also not possible to iterate through the subnodes and change individual nodes opacities. So there is no other way to change layer opacity except of remembering all the nodes in array and iterating through the array later.

Can CocosNode be extended to get all child nodes as an array or dictionary? I don't think child nodes are worth to be hidden

Comment #2

Posted on Feb 2, 2009 by Massive Lion

Only the nodes that supports the Opacity protocol can receive messages regarding it's opacity. The nodes that implements this protocol are listed here: http://www.sapusmedia.com/cocos2d-iphone-api-doc/protocol_cocos_node_opacity-p.html

Sure, I can make 'children' a readonly property

Comment #3

Posted on Feb 3, 2009 by Massive Lion

closing this ticket is invalid, since Scenes/Nodes doesn't support the CocosNodeOpacity protocol.

issue #185 has the 'children property' thing.

Status: Invalid

Labels:
Type-Defect Priority-Medium