本文整理汇总了C++中SkeletonDrawable::update方法的典型用法代码示例。如果您正苦于以下问题:C++ SkeletonDrawable::update方法的具体用法?C++ SkeletonDrawable::update怎么用?C++ SkeletonDrawable::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkeletonDrawable
的用法示例。
在下文中一共展示了SkeletonDrawable::update方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stretchyman
void stretchyman (SkeletonData* skeletonData, Atlas* atlas) {
SkeletonDrawable* drawable = new SkeletonDrawable(skeletonData);
drawable->timeScale = 1;
Skeleton* skeleton = drawable->skeleton;
skeleton->flipX = false;
skeleton->flipY = false;
skeleton->x = 320;
skeleton->y = 590;
Skeleton_updateWorldTransform(skeleton);
AnimationState_setAnimationByName(drawable->state, 0, "sneak", true);
sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - Streatchyman");
window.setFramerateLimit(60);
sf::Event event;
sf::Clock deltaClock;
while (window.isOpen()) {
while (window.pollEvent(event))
if (event.type == sf::Event::Closed) window.close();
float delta = deltaClock.getElapsedTime().asSeconds();
deltaClock.restart();
drawable->update(delta);
window.clear();
window.draw(*drawable);
window.display();
}
}
示例2: goblins
void goblins (SkeletonData* skeletonData, Atlas* atlas) {
SkeletonDrawable* drawable = new SkeletonDrawable(skeletonData);
drawable->timeScale = 1;
Skeleton* skeleton = drawable->skeleton;
skeleton->flipX = false;
skeleton->flipY = false;
Skeleton_setSkinByName(skeleton, "goblin");
Skeleton_setSlotsToSetupPose(skeleton);
//Skeleton_setAttachment(skeleton, "left hand item", "dagger");
skeleton->x = 320;
skeleton->y = 590;
Skeleton_updateWorldTransform(skeleton);
AnimationState_setAnimationByName(drawable->state, 0, "walk", true);
sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - goblins");
window.setFramerateLimit(60);
sf::Event event;
sf::Clock deltaClock;
while (window.isOpen()) {
while (window.pollEvent(event))
if (event.type == sf::Event::Closed) window.close();
float delta = deltaClock.getElapsedTime().asSeconds();
deltaClock.restart();
drawable->update(delta);
window.clear();
window.draw(*drawable);
window.display();
}
}
示例3: spineboy
void spineboy () {
// Load atlas, skeleton, and animations.
Atlas* atlas = Atlas_readAtlasFile("../data/spineboy.atlas");
SkeletonJson* json = SkeletonJson_create(atlas);
SkeletonData *skeletonData = SkeletonJson_readSkeletonDataFile(json, "../data/spineboy.json");
SkeletonJson_dispose(json);
// Configure mixing.
AnimationStateData* stateData = AnimationStateData_create(skeletonData);
AnimationStateData_setMixByName(stateData, "walk", "jump", 0.2f);
AnimationStateData_setMixByName(stateData, "jump", "walk", 0.4f);
SkeletonDrawable* drawable = new SkeletonDrawable(skeletonData, stateData);
drawable->timeScale = 1;
Skeleton* skeleton = drawable->skeleton;
skeleton->flipX = false;
skeleton->flipY = false;
Skeleton_setToBindPose(skeleton);
skeleton->root->x = 320;
skeleton->root->y = 420;
Skeleton_updateWorldTransform(skeleton);
AnimationState_setAnimationByName(drawable->state, "walk", true);
AnimationState_addAnimationByName(drawable->state, "jump", false, 0);
AnimationState_addAnimationByName(drawable->state, "walk", true, 0);
AnimationState_addAnimationByName(drawable->state, "jump", false, 3);
AnimationState_addAnimationByName(drawable->state, "walk", true, 0);
AnimationState_addAnimationByName(drawable->state, 0, true, 0);
AnimationState_addAnimationByName(drawable->state, "walk", false, 1);
sf::RenderWindow window(sf::VideoMode(640, 480), "Spine SFML");
window.setFramerateLimit(60);
sf::Event event;
sf::Clock deltaClock;
while (window.isOpen()) {
while (window.pollEvent(event))
if (event.type == sf::Event::Closed) window.close();
float delta = deltaClock.getElapsedTime().asSeconds();
deltaClock.restart();
/*if (drawable->state->loop) {
if (drawable->state->time > 2) AnimationState_setAnimationByName(drawable->state, "jump", false);
} else {
if (drawable->state->time > 1) AnimationState_setAnimationByName(drawable->state, "walk", true);
}*/
drawable->update(delta);
window.clear();
window.draw(*drawable);
window.display();
}
SkeletonData_dispose(skeletonData);
Atlas_dispose(atlas);
}
示例4: spineboy
void spineboy (SkeletonData* skeletonData, Atlas* atlas) {
SkeletonBounds* bounds = SkeletonBounds_create();
// Configure mixing.
AnimationStateData* stateData = AnimationStateData_create(skeletonData);
AnimationStateData_setMixByName(stateData, "walk", "jump", 0.2f);
AnimationStateData_setMixByName(stateData, "jump", "run", 0.2f);
SkeletonDrawable* drawable = new SkeletonDrawable(skeletonData, stateData);
drawable->timeScale = 1;
Skeleton* skeleton = drawable->skeleton;
skeleton->flipX = false;
skeleton->flipY = false;
Skeleton_setToSetupPose(skeleton);
skeleton->x = 320;
skeleton->y = 460;
Skeleton_updateWorldTransform(skeleton);
Slot* headSlot = Skeleton_findSlot(skeleton, "head");
drawable->state->listener = callback;
AnimationState_setAnimationByName(drawable->state, 0, "test", true);
AnimationState_addAnimationByName(drawable->state, 0, "walk", true, 0);
AnimationState_addAnimationByName(drawable->state, 0, "jump", false, 3);
AnimationState_addAnimationByName(drawable->state, 0, "run", true, 0);
sf::RenderWindow window(sf::VideoMode(640, 480), "Spine SFML - spineboy");
window.setFramerateLimit(60);
sf::Event event;
sf::Clock deltaClock;
while (window.isOpen()) {
while (window.pollEvent(event))
if (event.type == sf::Event::Closed) window.close();
float delta = deltaClock.getElapsedTime().asSeconds();
deltaClock.restart();
SkeletonBounds_update(bounds, skeleton, true);
sf::Vector2i position = sf::Mouse::getPosition(window);
if (SkeletonBounds_containsPoint(bounds, position.x, position.y)) {
headSlot->g = 0;
headSlot->b = 0;
} else {
headSlot->g = 1;
headSlot->b = 1;
}
drawable->update(delta);
window.clear();
window.draw(*drawable);
window.display();
}
SkeletonBounds_dispose(bounds);
}
示例5: goblins
void goblins () {
// Load atlas, skeleton, and animations.
Atlas* atlas = Atlas_createFromFile("data/goblins-mesh.atlas", 0);
SkeletonJson* json = SkeletonJson_create(atlas);
json->scale = 1.4f;
SkeletonData *skeletonData = SkeletonJson_readSkeletonDataFile(json, "data/goblins-mesh.json");
if (!skeletonData) {
printf("Error: %s\n", json->error);
exit(0);
}
SkeletonJson_dispose(json);
SkeletonDrawable* drawable = new SkeletonDrawable(skeletonData);
drawable->timeScale = 1;
Skeleton* skeleton = drawable->skeleton;
skeleton->flipX = false;
skeleton->flipY = false;
Skeleton_setSkinByName(skeleton, "goblin");
Skeleton_setSlotsToSetupPose(skeleton);
//Skeleton_setAttachment(skeleton, "left hand item", "dagger");
skeleton->x = 320;
skeleton->y = 590;
Skeleton_updateWorldTransform(skeleton);
AnimationState_setAnimationByName(drawable->state, 0, "walk", true);
sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - goblins");
window.setFramerateLimit(60);
sf::Event event;
sf::Clock deltaClock;
while (window.isOpen()) {
while (window.pollEvent(event))
if (event.type == sf::Event::Closed) window.close();
float delta = deltaClock.getElapsedTime().asSeconds();
deltaClock.restart();
drawable->update(delta);
window.clear();
window.draw(*drawable);
window.display();
}
SkeletonData_dispose(skeletonData);
Atlas_dispose(atlas);
}
示例6: goblins
void goblins () {
// Load atlas, skeleton, and animations.
Atlas* atlas = Atlas_readAtlasFile("../data/goblins.atlas");
SkeletonJson* json = SkeletonJson_create(atlas);
SkeletonData *skeletonData = SkeletonJson_readSkeletonDataFile(json, "../data/goblins.json");
Animation* walkAnimation = SkeletonData_findAnimation(skeletonData, "walk");
SkeletonJson_dispose(json);
SkeletonDrawable* drawable = new SkeletonDrawable(skeletonData);
drawable->timeScale = 1;
Skeleton* skeleton = drawable->skeleton;
skeleton->flipX = false;
skeleton->flipY = false;
Skeleton_setSkinByName(skeleton, "goblin");
Skeleton_setSlotsToBindPose(skeleton);
Skeleton_setAttachment(skeleton, "left hand item", "dagger");
skeleton->root->x = 320;
skeleton->root->y = 420;
Skeleton_updateWorldTransform(skeleton);
AnimationState_setAnimation(drawable->state, walkAnimation, true);
sf::RenderWindow window(sf::VideoMode(640, 480), "Spine SFML");
window.setFramerateLimit(60);
sf::Event event;
sf::Clock deltaClock;
while (window.isOpen()) {
while (window.pollEvent(event))
if (event.type == sf::Event::Closed) window.close();
float delta = deltaClock.getElapsedTime().asSeconds();
deltaClock.restart();
drawable->update(delta);
window.clear();
window.draw(*drawable);
window.display();
}
SkeletonData_dispose(skeletonData);
Atlas_dispose(atlas);
}
示例7: raptor
void raptor () {
// Load atlas, skeleton, and animations.
Atlas* atlas = Atlas_createFromFile("data/raptor.atlas", 0);
SkeletonJson* json = SkeletonJson_create(atlas);
json->scale = 0.5f;
SkeletonData *skeletonData = SkeletonJson_readSkeletonDataFile(json, "data/raptor.json");
if (!skeletonData) {
printf("Error: %s\n", json->error);
exit(0);
}
SkeletonJson_dispose(json);
SkeletonDrawable* drawable = new SkeletonDrawable(skeletonData);
drawable->timeScale = 1;
Skeleton* skeleton = drawable->skeleton;
skeleton->x = 320;
skeleton->y = 590;
Skeleton_updateWorldTransform(skeleton);
AnimationState_setAnimationByName(drawable->state, 0, "walk", true);
AnimationState_setAnimationByName(drawable->state, 1, "empty", false);
AnimationState_addAnimationByName(drawable->state, 1, "gungrab", false, 2);
sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - raptor");
window.setFramerateLimit(60);
sf::Event event;
sf::Clock deltaClock;
while (window.isOpen()) {
while (window.pollEvent(event))
if (event.type == sf::Event::Closed) window.close();
float delta = deltaClock.getElapsedTime().asSeconds();
deltaClock.restart();
drawable->update(delta);
window.clear();
window.draw(*drawable);
window.display();
}
SkeletonData_dispose(skeletonData);
Atlas_dispose(atlas);
}