This section describes how to interact with the objects in the scene, followed by the code in the previous section, where we go toward the cube object
Add the following code and implement its proxy<HitEventDelegate>
Code:
// create a cube nvboxwidget *cube = [[nvboxwidget alloc] initwithsceneplay:self widgetname:@ " Cube "]; // adds a material, passing in the corresponding material material name [cube setappearance:@ "Cubetex"]; // set coordinates [cube setposition:nvposition (0, 0, 0)]; // set zoom ratio [cube setscale:nvposition (1.0, 1.0, 1.0)]; // Set Click Pick Events [cube setClickEnadble]; cube.delegate = self; // adding objects to the scene [self addwidget:cube];
Click on the agent, you can see the method inside, we realize
Code:
Click Event-(void) OnClick: (Nvwidget *) widget {//clicked object is consistent with the object name of the cube if ([[Widget GetName] isequaltostring:@ "Cube"]) {NSLog (@ "Click to Cube"); } }
run the project and click on the cube to see the console print the log
With This proxy, you can interact with the objects in the scene. The contents of this chapter are ended here, the next chapter
section, I will teach you to let this cube move.
Welcome to contact:
Contact information: +86 18801341080
E-mail: [email protected]
Website: http://www.nvisionxr.com/
QQ Group: 416802300
Nvisionxr_ios Tutorial Six--object interaction in the scene