本章节教大家多个识别切换多个场景,接着上一章多场景切换的教程
1 、打开 StonesAndChips.xml ,我们可以看到有两张识别图 stones 和 chips ,这两张图都可以进行识别,接下来我们会根据这两张图分别绑定不同的场景。
2 、打开 NVisionController.m, 添加如下代码
代码:
欢迎联系:
1 、打开 StonesAndChips.xml ,我们可以看到有两张识别图 stones 和 chips ,这两张图都可以进行识别,接下来我们会根据这两张图分别绑定不同的场景。
2 、打开 NVisionController.m, 添加如下代码
代码:
// 实例话对象,传进来的name可以随意写,但是要唯一,相当于该对象的key。 // NVScenePlay,类似原生ios的控制器,也有着自己的一套生命周期,添加ar场景对象都需要在这里面操作。 MyFirstScene *firstScene = [[MyFirstScene alloc] initWithName:@"first_scene"]; // NVScenePlay的所属类别一般有 MAIN_SCENEPLAY 和 GENERAL_SCENEPLAY 两类 // 当设置为MAIN_SCENEPLAY时,该NVScenePlay会在程序启动时第一个被启动, // 当有多个场景时,只能唯一有一个NVScenePlay被设置为MAIN_SCENEPLAY,其余的都为GENERAL_SCENEPLAY。 [[NVAppDirector sharedNVAppDirector] addScenePlay:@"MAIN_SCENEPLAY" Scene:firstScene]; VideoScene *videoScene = [[VideoScene alloc] initWithName:@"video_scene"]; [[NVAppDirector sharedNVAppDirector] addScenePlay:@"GENERAL_SCENEPLAY" Scene:videoScene]; // 根据识别图绑定对应场景 // 将chips对应的图贴绑定到firstScene场景 [_vuforiaWrapper bindDataWithTrackerTarget:@"chips" ScenePlay:firstScene]; // 将stones对应的图贴绑定到videoScene场景 [_vuforiaWrapper bindDataWithTrackerTarget:@"stones" ScenePlay:videoScene];这样场景就和识别图一一绑定了,运行项目,进行测试。
欢迎联系:
- 联系方式: +86 18801341080
- 电子邮箱: [email protected]
- 网址:http://www.nvisionxr.com/
- QQ群:416802300