Domanda

Hi i have been exploring cocos3D and i was wondering how can i detect which submode of main CC3Node was touched. I am using following code:

rezNode = [CC3PODResourceNode nodeFromFile: @"BeachBall.pod"];
n = (CC3MeshNode*)[rezNode getNodeNamed: @"BeachBall"];
n.isOpaque = YES;
[self configureAndAddTemplate: n];

this will create main node, then i link a variable to child node

self.childNode =(CC3Node*)[n getMeshNodeNamed: @"BeachBall-submesh1"];
self.childNode.isTouchEnabled=YES;
self.childNode.visible=YES;

Now i want to detect touch on that particular node. My touch methods are firing but i am guessing how to check if touch was on self.childNode.

Edit: In cocos3D programming guide it is mentioned

Once these two steps have been completed, the nodeSelected:byTouchEvent:at: callback method of your customized CC3World subclass will automatically be invoked on each touch event. This callback includes the CC3Node instance that was touched, the type of touch, and the 2D location of the touch point, in the local coordinates of the CC3Layer.

First step is to integrate touch delegates and second is to set node property to visible and touchesEnabled. I have implemented both the steps but still this method nodeSelected:byTouchEvent:at: is not firing.

È stato utile?

Soluzione

Got the answer myself. As mentioned in test project we have to call pickNodeFromTapAt: or pickNodeFromTouchEvent:at: to automatic invoke nodeSelected:byTouchEvent:at:. What i was doing is that is was calling this pickNodeFromTouchEvent:at: in touchEvent touchBegan and i was overriding that method in my scene. That was the problem i don't have to override it as it is already declared in CC3Scene. So as soon as i removed the overrided method from my CustomSecene Class nodeSelected:byTouchEvent:at: was fired.

Hope this helps somebody

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top