cocos2dx c++:
//移除该骨骼动画
ArmatureDataManager::getInstance()->removeArmatureFileInfo("paobu.ExportJson");
// 连接该骨骼动画的资源
ArmatureDataManager::getInstance()->addArmatureFileInfo("paobu.ExportJson");
//创建动画
armature2=Armature::create("paobu");
//执行该骨骼动画序列中的第一个动画
armature2->getAnimation()->playWithIndex(0);
//缩放人物,如果在当初是设置了scale,则可能会出现人物被分解的状况
armature2->setScale(0.1);
//设置tag,便于以后控制
armature2->setTag(105);
//设置动画的位置
armature2->setPosition(Point(visibleSize.width*0.2, visibleSize.height*0.7));
//像场景添加人物骨骼动画
this->addChild(armature2,2);
cocos2dx lua:
local actionName = "huafeiziti";
local resourceName = "Common2/action/huafeiziti/huafeiziti.ExportJson";
if ccs.ArmatureDataManager:getInstance():getAnimationData(actionName) == nil then
ccs.ArmatureDataManager:getInstance():addArmatureFileInfo(resourceName);
end
if self.titleAction~=nil then
self.titleAction:removeFromParent();
self.titleAction:release();
self.titleAction=nil;
end
self.titleAction = ccs.Armature:create(actionName)
self.titleAction:setPosition(x,y);
self.rootWidget:addChild(self.titleAction,1);
self.titleAction:retain();
self.titleAction:getAnimation():play("action", 0, 1); //"action"是.ExportJson文件里的属性
//移除该骨骼动画
ArmatureDataManager::getInstance()->removeArmatureFileInfo("paobu.ExportJson");
// 连接该骨骼动画的资源
ArmatureDataManager::getInstance()->addArmatureFileInfo("paobu.ExportJson");
//创建动画
armature2=Armature::create("paobu");
//执行该骨骼动画序列中的第一个动画
armature2->getAnimation()->playWithIndex(0);
//缩放人物,如果在当初是设置了scale,则可能会出现人物被分解的状况
armature2->setScale(0.1);
//设置tag,便于以后控制
armature2->setTag(105);
//设置动画的位置
armature2->setPosition(Point(visibleSize.width*0.2, visibleSize.height*0.7));
//像场景添加人物骨骼动画
this->addChild(armature2,2);
cocos2dx lua:
local actionName = "huafeiziti";
local resourceName = "Common2/action/huafeiziti/huafeiziti.ExportJson";
if ccs.ArmatureDataManager:getInstance():getAnimationData(actionName) == nil then
ccs.ArmatureDataManager:getInstance():addArmatureFileInfo(resourceName);
end
if self.titleAction~=nil then
self.titleAction:removeFromParent();
self.titleAction:release();
self.titleAction=nil;
end
self.titleAction = ccs.Armature:create(actionName)
self.titleAction:setPosition(x,y);
self.rootWidget:addChild(self.titleAction,1);
self.titleAction:retain();
self.titleAction:getAnimation():play("action", 0, 1); //"action"是.ExportJson文件里的属性