void SkeletonAnimationFbo::setMix(const QString &fromAnimation, const QString &toAnimation, float duration) { if (!isSkeletonValid()){ qDebug()<<"SkeletonAnimation::setMix Error: Skeleton is not ready."; return; } spAnimationStateData_setMixByName(mspAnimationState->data, fromAnimation.toStdString().c_str(), toAnimation.toStdString().c_str(), duration); }
spAnimationStateData* USpineSkeletonDataAsset::GetAnimationStateData(spAtlas* atlas) { if (!animationStateData) { spSkeletonData* skeletonData = GetSkeletonData(atlas, false); animationStateData = spAnimationStateData_create(skeletonData); } for (auto& data : MixData) { if (!data.From.IsEmpty() && !data.To.IsEmpty()) { const char* fromChar = TCHAR_TO_UTF8(*data.From); const char* toChar = TCHAR_TO_UTF8(*data.To); spAnimationStateData_setMixByName(animationStateData, fromChar, toChar, data.Mix); } } animationStateData->defaultMix = DefaultMix; return this->animationStateData; }
void SkeletonAnimation::setMix (const std::string& fromAnimation, const std::string& toAnimation, float duration) { spAnimationStateData_setMixByName(_state->data, fromAnimation.c_str(), toAnimation.c_str(), duration); }
Player::Player(Game& g, b2Vec2 p) : Character(g),swordFix(NULL), left(false), right(false), landed(true), contact(false), lastproc(0), life(100), attacking(false), attackcooldown(0) { bodyDef.type = b2_dynamicBody; bodyDef.position.Set(p.x, p.y); bodyDef.fixedRotation = true; body = g.w.CreateBody(&bodyDef); dynamicBox.SetAsBox(.25f, 0.9f); fixtureDef.shape = &dynamicBox; fixtureDef.density = 5.0f; fixtureDef.friction = 0.0f; fixtureDef.filter.categoryBits = PLAYER; fixtureDef.filter.maskBits = MONSTER | TRIGGER | WALL | SWORD; (body->CreateFixture(&fixtureDef))->SetUserData(this); //add "feet" to detect floor dynamicBox.SetAsBox(0.2, 0.05, b2Vec2(0, 0.9f), 0); fixtureDef.isSensor = true; fixtureDef.density = 0.1; fixtureDef.filter.categoryBits = FOOT; fixtureDef.filter.maskBits = WALL | MONSTER; (body->CreateFixture(&fixtureDef))->SetUserData(this); //add sword to kill monsters dynamicBox.SetAsBox(0.4, 0.1, b2Vec2(0.65, 0), 0); swordDef.shape = &dynamicBox; swordDef.isSensor = true; swordDef.density = 0.1; swordDef.filter.categoryBits = SWORD; swordDef.filter.maskBits = MONSTER; // Loads the Spine model ALLEGRO_PATH *path, *resourceDir, *file; resourceDir= al_get_standard_path(ALLEGRO_RESOURCES_PATH); std::cerr << al_path_cstr(resourceDir, ALLEGRO_NATIVE_PATH_SEP) << std::endl; if (modelAtlas == NULL) { file = al_create_path("data/animations/hero.atlas"); path = al_clone_path(resourceDir); al_join_paths(path, file); al_destroy_path(file); modelAtlas = spAtlas_createFromFile(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP), NULL); if (!modelAtlas) throw Failure("Failed to load the hero's atlas."); al_destroy_path(path); jsonSkel = spSkeletonJson_create(modelAtlas); file = al_create_path("data/animations/hero.json"); path = al_clone_path(resourceDir); al_join_paths(path, file); al_destroy_path(file); modelData = spSkeletonJson_readSkeletonDataFile(jsonSkel, al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP)); if (!modelData) throw Failure("Failed to load the hero's data."); al_destroy_path(path); al_destroy_path(resourceDir); stateData = spAnimationStateData_create(modelData); spAnimationStateData_setMixByName(stateData, "walk", "rest", 0.2f); spAnimationStateData_setMixByName(stateData, "rest", "walk", 0.2f); spAnimationStateData_setMixByName(stateData, "rest", "slash", 0.1f); spAnimationStateData_setMixByName(stateData, "slash", "rest", 0.1f); spAnimationStateData_setMixByName(stateData, "walk", "slash", 0.1f); spAnimationStateData_setMixByName(stateData, "slash", "walk", 0.1f); model = loadSkeleton(modelData, stateData); if (!model) throw Failure("Failed to load the hero's skeleton."); spAnimationState_setAnimationByName(model->state, 0, "rest", true); } }
void SkeletonAnimation::setMix (const char* fromAnimation, const char* toAnimation, float duration) { spAnimationStateData_setMixByName(state->data, fromAnimation, toAnimation, duration); }
void Skeleton::set_animation_mix(const char* from, const char* to, float duration) { spAnimationStateData_setMixByName(animation_data_, from, to, duration); }