本文整理汇总了C++中SkeletonDrawable类的典型用法代码示例。如果您正苦于以下问题:C++ SkeletonDrawable类的具体用法?C++ SkeletonDrawable怎么用?C++ SkeletonDrawable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SkeletonDrawable类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: goblins
void goblins () {
// Load atlas, skeleton, and animations.
Atlas* atlas = Atlas_readAtlasFile("../data/goblins.atlas");
SkeletonJson* json = SkeletonJson_create(atlas);
json->scale = 2;
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_setSlotsToSetupPose(skeleton);
// Skeleton_setAttachment(skeleton, "left hand item", "dagger");
skeleton->x = 320;
skeleton->y = 590;
Skeleton_updateWorldTransform(skeleton);
AnimationState_setAnimation(drawable->state, 0, walkAnimation, true);
sf::RenderWindow window(sf::VideoMode(640, 640), "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);
}
示例2: 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);
}
示例3: spineboy
void spineboy () {
// Load atlas, skeleton, and animations.
Atlas* atlas = Atlas_createFromFile("data/spineboy.atlas", 0);
SkeletonJson* json = SkeletonJson_create(atlas);
json->scale = 0.6f;
SkeletonData *skeletonData = SkeletonJson_readSkeletonDataFile(json, "data/spineboy.json");
if (!skeletonData) {
printf("%s\n", json->error);
exit(0);
}
SkeletonJson_dispose(json);
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();
}
SkeletonData_dispose(skeletonData);
SkeletonBounds_dispose(bounds);
Atlas_dispose(atlas);
}