1

I am using Cocos3D and this function give me a 'may not respond' warning:

[CClayer.CC3scene someFunctionFromCC3scene];

I know one way to resolve this is to have a Function in CCLayer to make CC3scene call someFunctionFromCC3scene. But is there any other way to do this? Thanks!

Martin Schröder
  • 4,176
  • 7
  • 47
  • 81
sooon
  • 4,718
  • 8
  • 63
  • 116

2 Answers2

1

More likely you're not importing the corresponding header. For example #import "CC3Scene.h". I suppose this can happen if the return type of the CC3scene property is id instead of the actual class.

Or the compiler is correct about this and it will crash with "does not respond to selector" when you run it. In that case CC3Scene does not implement the someFunctionFromCC3scene selector. Check spelling and parameters, and of course that the class actually implements that selector and has it declared in the @interface.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
1

From the look of your example, there are several things that might be going wrong:

You might be confusing CCLayer with CC3Layer. CC3Layer is a subclass of CCLayer that supports displaying a 3D scene. Be sure you are instantiating a CC3Layer.

If you really are using a CC3Layer and the CC3Scene property (which is actually cc3Scene) is returning an instance of CC3Scene, then, as LearnCocos2D indicates, verify that the method you are invoking actually exists in the CC3Scene class. If you provide the specific method name here, then I can provide further help.

If the someFunctionFromCC3Scene is actually defined and implemented in your custom subclass, then you should cast the CC3Scene instance to your custom subclass before invoking that method:

[((MyCC3Scene*)aCC3Layer.cc3Scene) someFunctionFromMyCC3Scene];

...Bill

Bill Hollings
  • 2,344
  • 17
  • 25
  • Strange. The function is called. But I get this `[info] Deallocating TepaScene 'Unnamed':22 on thread {name = (null), num = 1}` and the code inside the function is not being performed. – AlexanderZ Jul 09 '14 at 21:16
  • I went other way and managed it by NSNotificationCenter. But still wonder what was causing this error. – AlexanderZ Jul 10 '14 at 11:48