This is not a problem of the cast. If you peform loadAsScene
the CCBReader
will wrap the Gameplay.ccb root node into a scene.
You can read that in the documentation:
... Loads a ccbi-file with the specified name and wraps it in a CCScene node.
If you use the console to print the children of this node:
(lldb) po scene.children
You will get following result:
<__NSArrayM 0x13a38720>(
<Gameplay = 0x13a3f8a0 | Name = >
)
This shows how your gameplay class is wrapped into a CCScene
.
If you want to access the Gameplay
node you need to access the first child of the CCScene
:
Gameplay *gameplay = (Gameplay *)[[CCBReader loadAsScene:@"GameplayScene"] children] [0];
Feel free to use a different solution that doesn't do all the work in one line.