本文整理汇总了C++中SkeletonAnimation类的典型用法代码示例。如果您正苦于以下问题:C++ SkeletonAnimation类的具体用法?C++ SkeletonAnimation怎么用?C++ SkeletonAnimation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SkeletonAnimation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkeletonAnimation
SkeletonAnimation* SkeletonAnimation::createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData) {
skeletonData->refCount++;
skeletonData->ifRefed = 1;
SkeletonAnimation* node = new SkeletonAnimation(skeletonData, ownsSkeletonData);
node->autorelease();
return node;
}
示例2: LoadComponent
bool CSmeltArmor::init()
{
if (BaseLayer::init())
{
m_ui = LoadComponent("RinseItem.xaml"); //
m_ui->setPosition(VCENTER);
this->addChild(m_ui);
this->setIsShowBlack(false);
m_attr = (CLayout*)m_ui->findWidgetById("attr");
//获取cell
m_pCellInfo = (CLayout*)m_ui->findWidgetById("cell_info");
CC_SAFE_RETAIN(m_pCellInfo);
m_pCellInfo->removeFromParentAndCleanup(false);
CCPoint pBasePos = ccp(1281, 160);
//初始化基础属性四条
initItemInfo(pBasePos, m_pBaseInfo, 4);
//添加动画
SkeletonAnimation *pSkeletonAnimation = SkeletonAnimation::createWithFile("strengthen/5002.json", "strengthen/5002.atlas", 1);
pSkeletonAnimation->setPosition(ccp(887, -2));
pSkeletonAnimation->setAnimation(0, "stand", true);
m_ui->addChild(pSkeletonAnimation, 3);
m_pSpineHero = pSkeletonAnimation;
return true;
}
return false;
}
示例3: GetTicksPerFrame
void MeshExporter::_dumpAnimation(IGameControl * pGameControl, int boneId)
{
int start = ExportConfig::Instance()->GetFrameRange().x;
int end = ExportConfig::Instance()->GetFrameRange().y;
start *= GetTicksPerFrame();
end *= GetTicksPerFrame();
if ((pGameControl->IsAnimated(IGAME_POS)) || pGameControl->IsAnimated(IGAME_ROT) || pGameControl->IsAnimated(IGAME_SCALE))
{
IGameKeyTab Key;
if(pGameControl->GetFullSampledKeys(Key, 1, IGAME_TM, true) )
{
SkeletonAnimation * skelAnim = new SkeletonAnimation(boneId);
int count = Key.Count();
for(int i=0;i<count;i++)
{
if (Key[i].t >= start && Key[i].t <= end)
{
float time = (float)Key[i].t / (float)GetTicksPerFrame() / (float)GetFrameRate();
SkeletonAnimation::KeyFrame * kf = skelAnim->CreateKeyFrame(time);
kf->position = Utility::ToFloat3(Key[i].sampleKey.gval.Translation());
kf->rotation = Utility::ToQuat(Key[i].sampleKey.gval.Rotation());
kf->scale = Utility::ToFloat3(Key[i].sampleKey.gval.Scaling());
}
}
skelAnim->Optimize();
_getAnimation()->AddSkeletonAnimation(skelAnim);
}
}
}
示例4: SkeletonAnimation
SkeletonAnimation* SkeletonAnimation::createWithJsonFile (const std::string& skeletonJsonFile, const std::string& atlasFile, float scale) {
SkeletonAnimation* node = new SkeletonAnimation();
spAtlas* atlas = spAtlas_createFromFile(atlasFile.c_str(), 0);
node->initWithJsonFile(skeletonJsonFile, atlas, scale);
node->autorelease();
return node;
}
示例5: log
void SpineTest::testSimple(Object *sender)
{
log("testSimple");
SkeletonAnimation *node = SkeletonAnimation::createWithFile("player.json", "player.atlas");
node->setAnimation(0, "walk", true);
node->setPosition(Point(200, 200));
addChild(node);
}
示例6: while
bool BinaryParser< SkeletonAnimation >::doParse( SkeletonAnimation & obj )
{
bool result = true;
SkeletonAnimationNodeSPtr node;
SkeletonAnimationObjectSPtr object;
SkeletonAnimationBoneSPtr bone;
SkeletonAnimationKeyFrameUPtr keyFrame;
String name;
BinaryChunk chunk;
while ( result && doGetSubChunk( chunk ) )
{
switch ( chunk.getChunkType() )
{
case ChunkType::eSkeletonAnimationNode:
node = std::make_shared< SkeletonAnimationNode >( obj );
result = BinaryParser< SkeletonAnimationNode >{}.parse( *node, chunk );
if ( result )
{
obj.addObject( node, nullptr );
}
break;
case ChunkType::eSkeletonAnimationBone:
bone = std::make_shared< SkeletonAnimationBone >( obj );
result = BinaryParser< SkeletonAnimationBone >{}.parse( *bone, chunk );
if ( result )
{
obj.addObject( bone, nullptr );
}
break;
case ChunkType::eSkeletonAnimationKeyFrame:
keyFrame = std::make_unique< SkeletonAnimationKeyFrame >( obj );
result = BinaryParser< SkeletonAnimationKeyFrame >{}.parse( *keyFrame, chunk );
if ( result )
{
obj.addKeyFrame( std::move( keyFrame ) );
}
break;
}
}
return result;
}
示例7: getAnimation
void Skeleton::playAnimation(const String& animName, bool once) {
SkeletonAnimation *anim = getAnimation(animName);
if(!anim)
return;
if(anim == currentAnimation && !once)
return;
if(currentAnimation)
currentAnimation->Stop();
currentAnimation = anim;
anim->Play(once);
}
示例8: CCLOG
void TrapObject::initSpineTrap()
{
SpineData* tData = SpineManage->getSpineData(ToString(mData->getTrapModel()));
if (!tData)
{
tData = SpineManage->getSpineData("10000");
CCLOG("[ *ERROR ] TrapObject::init Spine Model=%d IS NULL",mData->getTrapModel());
}
SkeletonAnimation* Animation = SkeletonAnimation::createWithData(tData->first);
CCAssert(Animation,"TrapObject::init Spine NULL");
Animation->setAnimation(0,"standby",true);
Animation->setRotation(mData->getRotation());
mTrapNode = Animation;
this->addChild(mTrapNode);
}
示例9: new
void SkeletonAnimationManager::ReloadAssets()
{
Engine *eng = Engine::Get();
const ResourcePool<SkeletonAnimation>::Iterator end = resPool->End();
for(ResourcePool<SkeletonAnimation>::Iterator iter = resPool->Begin(); iter != end; ++iter) {
SkeletonAnimation *skelAnim = iter.Ptr();
Rid rid = skelAnim->rid;
if(rid != RID_NONE) {
skelAnim->~SkeletonAnimation();
new(skelAnim) SkeletonAnimation();
skelAnim->Load(rid);
}
}
}
示例10: getGLProgramState
// draw all children to batch. Recursive iteration not support yet.
void SpineBatchNode::onDrawSkeletonBatch(const Mat4 &transform, uint32_t transformFlags) {
getGLProgramState()->apply(transform);
if (Configuration::getInstance()->supportsShareableVAO())
{
_batch->setupVBOAndVAO();
}
for (auto child : _children) {
SkeletonAnimation *skeletonNode = static_cast<SkeletonAnimation*>(child);
if (skeletonNode) {
skeletonNode->onDrawSkeleton(_batch);
}
}
_batch->flush();
}
示例11: playAnimationByIndex
void Skeleton::playAnimationByIndex(int index, bool once) {
if(index > animations.size()-1)
return;
SkeletonAnimation *anim = animations[index];
if(!anim)
return;
if(anim == currentAnimation && !once)
return;
if(currentAnimation)
currentAnimation->Stop();
currentAnimation = anim;
anim->Play(once);
}
示例12: spAtlas_createFromFile
bool BatchingExample::init () {
if (!LayerColor::initWithColor(Color4B(128, 128, 128, 255))) return false;
// To avoid the SkeletonBatch buffer from being resized, set this to the number of vertices ever rendered in one frame.
// BatchingExample needs ~3200, but let's set it low to test the buffer resizing.
SkeletonBatch::setBufferSize(512);
// Load the texture atlas.
_atlas = spAtlas_createFromFile("spineboy.atlas", 0);
CCASSERT(_atlas, "Error reading atlas file.");
// This attachment loader configures attachments with data needed for cocos2d-x rendering.
// Do not dispose the attachment loader until the skeleton data is disposed!
_attachmentLoader = (spAttachmentLoader*)Cocos2dAttachmentLoader_create(_atlas);
// Load the skeleton data.
spSkeletonJson* json = spSkeletonJson_createWithLoader(_attachmentLoader);
json->scale = 0.6f; // Resizes skeleton data to 60% of the size it was in Spine.
_skeletonData = spSkeletonJson_readSkeletonDataFile(json, "spineboy.json");
CCASSERT(_skeletonData, json->error ? json->error : "Error reading skeleton data file.");
spSkeletonJson_dispose(json);
// Setup mix times.
_stateData = spAnimationStateData_create(_skeletonData);
spAnimationStateData_setMixByName(_stateData, "walk", "jump", 0.2f);
spAnimationStateData_setMixByName(_stateData, "jump", "run", 0.2f);
int xMin = _contentSize.width * 0.10f, xMax = _contentSize.width * 0.90f;
int yMin = 0, yMax = _contentSize.height * 0.7f;
for (int i = 0; i < 50; i++) {
// Each skeleton node shares the same atlas, skeleton data, and mix times.
SkeletonAnimation* skeletonNode = SkeletonAnimation::createWithData(_skeletonData, false);
skeletonNode->setAnimationStateData(_stateData);
skeletonNode->setAnimation(0, "walk", true);
skeletonNode->addAnimation(0, "jump", false, 3);
skeletonNode->addAnimation(0, "run", true);
skeletonNode->setPosition(Vec2(
RandomHelper::random_int(xMin, xMax),
RandomHelper::random_int(yMin, yMax)
));
addChild(skeletonNode);
}
scheduleUpdate();
EventListenerTouchOneByOne* listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = [this] (Touch* touch, Event* event) -> bool {
Director::getInstance()->replaceScene(SpineboyExample::scene());
return true;
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
return true;
}
示例13: setAnimation
void SkeletonAnimationKeysChart::setAnimation( SkeletonAnimation& animation )
{
// clear the charts
for ( ChartsMap::iterator it = m_charts.begin(); it != m_charts.end(); ++it )
{
delete it->second;
}
m_charts.clear();
// set the new animation
m_animation = &animation;
// set the time range
float animLength = animation.getAnimationLength();
float maxVal = 100.0f * ANIMATION_VALUE_SCALE; // we can edit an animation up to 100 meters - should be more than enough
setSceneRect( 0, -maxVal, animLength * ANIMATION_TIME_SCALE, 2.0f * maxVal );
}
示例14: SkeletonAnimation
SkeletonAnimation* SkeletonAnimation::createWithFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale) {
SkeletonAnimation* node = new SkeletonAnimation(skeletonDataFile, atlasFile, scale);
node->autorelease();
return node;
}
示例15: sizeof
void Skeleton::addAnimation(const String& name, const String& fileName) {
OSFILE *inFile = OSBasics::open(fileName.c_str(), "rb");
if(!inFile) {
return;
}
unsigned int activeBones,numPoints,numCurves, curveType;
float length;
OSBasics::read(&length, 1, sizeof(float), inFile);
SkeletonAnimation *newAnimation = new SkeletonAnimation(name, length);
OSBasics::read(&activeBones, sizeof(unsigned int), 1, inFile);
unsigned short boneNameLen;
char boneNameBuffer[1024];
for(int j=0; j < activeBones; j++) {
OSBasics::read(&boneNameLen, sizeof(unsigned short), 1, inFile);
OSBasics::read(boneNameBuffer, 1, boneNameLen, inFile);
boneNameBuffer[boneNameLen] = '\0';
Bone *trackBone = getBoneByName(boneNameBuffer);
if(!trackBone) {
printf("WARNING, INVALID BONE NAME: %s\n", boneNameBuffer);
continue;
}
BoneTrack *newTrack = new BoneTrack(trackBone, length);
BezierCurve *curve;
float vec1[2];
OSBasics::read(&numCurves, sizeof(unsigned int), 1, inFile);
for(int l=0; l < numCurves; l++) {
curve = new BezierCurve();
OSBasics::read(&curveType, sizeof(unsigned int), 1, inFile);
OSBasics::read(&numPoints, sizeof(unsigned int), 1, inFile);
for(int k=0; k < numPoints; k++) {
OSBasics::read(vec1, sizeof(float), 2, inFile);
curve->addControlPoint2d(vec1[1], vec1[0]);
}
switch(curveType) {
case 0:
newTrack->scaleX = curve;
break;
case 1:
newTrack->scaleY = curve;
break;
case 2:
newTrack->scaleZ = curve;
break;
case 3:
newTrack->QuatW = curve;
break;
case 4:
newTrack->QuatX = curve;
break;
case 5:
newTrack->QuatY = curve;
break;
case 6:
newTrack->QuatZ = curve;
break;
case 7:;
newTrack->LocX = curve;
break;
case 8:
newTrack->LocY = curve;
break;
case 9:
newTrack->LocZ = curve;
break;
}
}
newAnimation->addBoneTrack(newTrack);
}
animations.push_back(newAnimation);
OSBasics::close(inFile);
}