Sprite3D
来源:互联网 发布:改革开放 知乎 编辑:程序博客网 时间:2024/04/30 10:17
//创建第一个3D对象
Sprite3D * sp = Sprite3D::create("boss.obj","boss.png");
sp->setScale(17.f);
sp->setPosition(visibleSize/2);
sp->runAction(RepeatForever::create(RotateBy::create(0.1, 10)));
addChild(sp);
//创建第二个对象
Sprite3D * sp_1 = Sprite3D::create("boss.obj","boss.png");
sp_1->setScale(17.f);
sp_1->setPosition(visibleSize/2);
sp_1->setAnchorPoint(Vec2(0.5,0.5));
sp_1->runAction(RepeatForever::create(RotateBy::create(0.1, 10)));
addChild(sp_1);
//创建触摸监听
auto lis = EventListenerTouchOneByOne::create();
lis->setSwallowTouches(true);
//用lambda表达式对回调函数的实现
lis->onTouchBegan=[](Touch * touch,Event * e){
auto target = (Sprite3D*)(e->getCurrentTarget());
Rect rect = target->getBoundingBox();
if (rect.containsPoint(touch->getLocation())) {
CCLOG("sprite3d began... x = %f, y = %f", touch->getLocation().x, touch->getLocation().y);
target->setOpacity(100);
return true;
}
return false;
};
lis->onTouchMoved=[](Touch * touch,Event * e){
auto target = (Sprite3D*)(e->getCurrentTarget());
target->setPosition(target->getPosition()+touch->getDelta());
};
lis->onTouchEnded=[](Touch * touch,Event * e){
auto target = (Sprite3D*)(e->getCurrentTarget());
target->setOpacity(255);
};
//事件分发器 分别分发给两个不同的对象
_eventDispatcher->addEventListenerWithSceneGraphPriority(lis, sp);
_eventDispatcher->addEventListenerWithSceneGraphPriority(lis->clone(), sp_1);
Sprite3D * sp = Sprite3D::create("boss.obj","boss.png");
sp->setScale(17.f);
sp->setPosition(visibleSize/2);
sp->runAction(RepeatForever::create(RotateBy::create(0.1, 10)));
addChild(sp);
//创建第二个对象
Sprite3D * sp_1 = Sprite3D::create("boss.obj","boss.png");
sp_1->setScale(17.f);
sp_1->setPosition(visibleSize/2);
sp_1->setAnchorPoint(Vec2(0.5,0.5));
sp_1->runAction(RepeatForever::create(RotateBy::create(0.1, 10)));
addChild(sp_1);
//创建触摸监听
auto lis = EventListenerTouchOneByOne::create();
lis->setSwallowTouches(true);
//用lambda表达式对回调函数的实现
lis->onTouchBegan=[](Touch * touch,Event * e){
auto target = (Sprite3D*)(e->getCurrentTarget());
Rect rect = target->getBoundingBox();
if (rect.containsPoint(touch->getLocation())) {
CCLOG("sprite3d began... x = %f, y = %f", touch->getLocation().x, touch->getLocation().y);
target->setOpacity(100);
return true;
}
return false;
};
lis->onTouchMoved=[](Touch * touch,Event * e){
auto target = (Sprite3D*)(e->getCurrentTarget());
target->setPosition(target->getPosition()+touch->getDelta());
};
lis->onTouchEnded=[](Touch * touch,Event * e){
auto target = (Sprite3D*)(e->getCurrentTarget());
target->setOpacity(255);
};
//事件分发器 分别分发给两个不同的对象
_eventDispatcher->addEventListenerWithSceneGraphPriority(lis, sp);
_eventDispatcher->addEventListenerWithSceneGraphPriority(lis->clone(), sp_1);
0 0
- Sprite3D
- Aternativa3D中的Sprite3D用法
- Sprite3D模型本身遮挡问题
- 21.cocos2d-x小鱼Sprite3D
- 使用JSR-184里的Sprite3D对象
- cocos2d-x 学习笔记1 Sprite3D
- cocos2d-x 3.3 Sprite3D人物换装代码解析
- Sprite3D在UI层的绘制和遮挡
- cocos2d-x 3.4 sprite3d c3b 模型无法显示的问题
- Sprite3D学习笔记(一):3D模型的换装功能.
- 从Sprite3D理解3D骨骼动画原理
- Cocos2dx 3.0 过渡篇(三十)灰机还是3D好(Sprite3D)
- Activity的生命周期
- Android导入Liblary包后报Value = 2系列错误
- Connect to localdb in Visual Studio 2015
- IOS 数组你知多少?
- C++11定义的数据类型
- Sprite3D
- QT学习之路(8):事件的传递和忽略
- iPhone - 读取工程包中的二进制文件
- @()、@[]、@{}
- Eclipse中java工程转web工程的方法
- CGRectGetMaxX/Y 使用
- 知道自己菜,所以要努力
- 2015年总结
- iOS中正则表达式的使用--NSPredicate