23.cocos2d-x骨骼动画
来源:互联网 发布:马克飞象 linux 编辑:程序博客网 时间:2024/05/16 16:10
温馨提示:
Tests-V3.8\tests\cpp-tests\Resources\spine文件夹下有raptor.atlas、raptor.json、raptor.png文件
HelloWorldScene.h文件
#ifndef __HELLOWORLD_SCENE_H__#define __HELLOWORLD_SCENE_H__#include "cocos2d.h"class HelloWorld : public cocos2d::Layer{public: // there's no 'id' in cpp, so we recommend returning the class instance pointer static cocos2d::Scene* createScene(); // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone virtual bool init(); // implement the "static create()" method manually CREATE_FUNC(HelloWorld);};#endif // __HELLOWORLD_SCENE_H__
HelloWorldScene.cpp文件
#include "HelloWorldScene.h"#include "cocostudio/CocoStudio.h"#include "ui/CocosGUI.h"#include "spine\spine.h"#include <spine/spine-cocos2dx.h>USING_NS_CC;using namespace spine;using namespace cocostudio::timeline;Scene* HelloWorld::createScene(){ // 'scene' is an autorelease object auto scene = Scene::create(); // 'layer' is an autorelease object auto layer = HelloWorld::create(); // add layer as a child to scene scene->addChild(layer); // return the scene return scene;}// on "init" you need to initialize your instancebool HelloWorld::init(){ ////////////////////////////// // 1. super init first if ( !Layer::init() ) { return false; } auto rootNode = CSLoader::createNode("MainScene.csb"); Vec2 visiable = Director::getInstance()->getVisibleSize(); auto skeletonNode = new SkeletonAnimation("raptor.json","raptor.atlas"); skeletonNode->setPosition(Vec2(visiable.x /2, 50)); skeletonNode->setScale(0.5); //0.一个一个执行,过度时不会卡顿 //skeletonNode->setMix("walk","gungrab",0.5f); //1.轨道、走路动作、是否循环 skeletonNode->setAnimation(0, "walk", true); ////2.setAnimation方法只能播放一种动画,所以当要连续播放不同的动画时,需要使用addAnimation方法来实现,它可以一条一条的播放不同的动画。 skeletonNode->setAnimation(1, "empty", false); skeletonNode->addAnimation(1, "gungrab", false, 2); //3.动画的播放快慢 skeletonNode->setTimeScale(0.5f); //4.是否显示骨骼 skeletonNode->setDebugBonesEnabled(true); addChild(skeletonNode); addChild(rootNode); return true;}
0 0
- 23.cocos2d-x骨骼动画
- cocos2d-x 骨骼动画详解
- 【Cocos2d-x 016】 骨骼动画
- Cocos2d-x加载骨骼动画
- Cocos2d-x 创建骨骼动画
- Cocos2d-x 3.0 骨骼动画
- cocos2d-x播放骨骼动画
- cocos2d-x 使用骨骼动画
- cocos2d-x骨骼动画使用
- 【cocos2d-x官方文档】骨骼动画详解
- 【cocos2d-x官方文档】骨骼动画详解
- cocos2d-x 骨骼动画初步了解
- 【cocos2d-x官方文档】骨骼动画详解
- quick-cocos2d-x spine 骨骼动画(1)
- quick-cocos2d-x spine 骨骼动画(2)
- Cocos2d-x 中加载骨骼动画资源
- cocos2d-x骨骼动画使用实例
- cocos2d-x 切换骨骼动画时残影问题
- 27. Remove Element
- 产品经理 面试题2
- 关于SQL中使用正则表达式的一些笔记
- android SwitchButton 纯代码实现,仿5.0原生
- EAIntroView–高度可定制的iOS应用欢迎页通用解决方案
- 23.cocos2d-x骨骼动画
- 4. Layout overview
- 从零开始使用Eclipse搭建NDK项目
- Burpsuite插件开发之RSA加解密
- 时间格式的转换 生成指定长度的随机字符串
- distinct误区
- eclipse的快捷键
- 图书管理系统
- MySQL学习笔记-MHA安装配置