本文整理汇总了C++中AnimatedSprite::play方法的典型用法代码示例。如果您正苦于以下问题:C++ AnimatedSprite::play方法的具体用法?C++ AnimatedSprite::play怎么用?C++ AnimatedSprite::play使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnimatedSprite
的用法示例。
在下文中一共展示了AnimatedSprite::play方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AnimatedSprite
pacman::pacman(sf::Texture spr)
{
//ctor
xpos = 250;
ypos = 500;
xvel = 0;
yvel = 0;
text = spr;
upan.setSpriteSheet(text);
upan.addFrame(sf::IntRect(0, 0, 25, 25));
upan.addFrame(sf::IntRect(75, 0, 25, 25));
downan.setSpriteSheet(text);
downan.addFrame(sf::IntRect(0, 0, 25, 25));
downan.addFrame(sf::IntRect(25, 0, 25, 25));
leftan.setSpriteSheet(text);
leftan.addFrame(sf::IntRect(0, 0, 25, 25));
leftan.addFrame(sf::IntRect(100, 0, 25, 25));
rightan.setSpriteSheet(text);
rightan.addFrame(sf::IntRect(0, 0, 25, 25));
rightan.addFrame(sf::IntRect(50, 0, 25, 25));
currentanim = &leftan;
anspr = AnimatedSprite(sf::seconds(.2f), false, true);
anspr.setPosition(sf::Vector2f(xpos, ypos));
//std::cout << "1 pacman" << std::endl;
anspr.play(*currentanim);
//sprite.setPosition(xpos, ypos);
collision_box = sprite.getGlobalBounds();
dir = 3;
}
示例2: set_curr_anim
void pacman::set_curr_anim(int d){
if (d == 0){
currentanim = &upan;
} else if (d == 1){
currentanim = &downan;
} else if (d == 2){
currentanim = &rightan;
} else {
currentanim = &leftan;
}
anspr.play(*currentanim);
}
示例3:
AnimatedSprite *StatusEffect::getIcon()
{
if (mIcon.empty())
return NULL;
else {
AnimatedSprite *sprite = AnimatedSprite::load(
"graphics/sprites/" + mIcon);
if (false && sprite) {
sprite->play(ACTION_DEFAULT);
sprite->reset();
}
return sprite;
}
}
示例4:
void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) {
ERR_FAIL_COND(!nodes.has(p_node));
{
RigidBody2D *rb = Object::cast_to<RigidBody2D>(p_node);
if (rb) {
rb->set_sleeping(!p_enabled);
}
}
{
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
if (ap) {
ap->set_active(p_enabled);
}
}
{
AnimatedSprite *as = Object::cast_to<AnimatedSprite>(p_node);
if (as) {
if (p_enabled)
as->play();
else
as->stop();
}
}
{
Particles2D *ps = Object::cast_to<Particles2D>(p_node);
if (ps) {
ps->set_emitting(p_enabled);
}
}
}
示例5: colorizer
MainMenu() : system(TextureManager::instance().getTexture("assets/rticle.png"))
{
pointer.setTexture(TextureManager::instance().getTexture("assets/two_pointer.png"));
//pointer.setPosition(1183, 427);
//system = new thor::ParticleSystem();
emitter.setEmissionRate(0.5f);
emitter.setParticleLifetime( sf::seconds(40) );
emitter.setParticleRotation( thor::Distributions::uniform(0.f, 360.f) );
emitter.setParticlePosition( sf::Vector2f(1260,740) );
emitter.setParticleScale(sf::Vector2f(0.1,0.1));
system.addEmitter(thor::refEmitter(emitter));
thor::ColorGradient gradient;
gradient[0.0f] = sf::Color::Magenta;
gradient[0.1f] = sf::Color::Red;
gradient[0.2f] = sf::Color::Blue;
gradient[0.3f] = sf::Color::Cyan;
gradient[0.4f] = sf::Color::Green;
gradient[0.5f] = sf::Color::Red;
gradient[0.6f] = sf::Color::Magenta;
gradient[0.7f] = sf::Color::Cyan;
gradient[0.8f] = sf::Color::Red;
gradient[0.9f] = sf::Color::Blue;
gradient[1.0f] = sf::Color::Red;
thor::ColorAnimation colorizer(gradient);
thor::FadeAnimation fader(0.1f, 0.1f);
system.addAffector( thor::ScaleAffector(sf::Vector2f(0.1f,0.1)));
system.addAffector( thor::AnimationAffector(fader) );
system.addAffector( thor::AnimationAffector(colorizer) );
sprite = AnimatedSprite(sf::seconds(0.3));
v.setTexture(TextureManager::instance().getTexture("assets/one_upper.png"));
back2.setTexture(TextureManager::instance().getTexture("assets/two_menu.png"));
logo.setTexture(TextureManager::instance().getTexture("assets/one_logo.png"));
press.setTexture(TextureManager::instance().getTexture("assets/one_anybutton.png"));
anim.setSpriteSheet(TextureManager::instance().getTexture("assets/one_animooted.jpg"));
for (int i = 0; i < 5; i++)
{
anim.addFrame(sf::IntRect(0, 800 * i, WIDTH, HEIGHT));
}
sprite.setAnimation(anim);
sprite.setLooped(true);
sprite.play();
logo.setColor(sf::Color(255,255,255,0));
press.setColor(sf::Color(255,255,255,0));
pointer.setColor(sf::Color(255,255,255,0));
press.setPosition(WIDTH/2 - press.getTextureRect().width/2, HEIGHT/2 - press.getTextureRect().height/2 + 100);
pressFading = true;
newLogoY = 800;
oTweener.addTween(&CDBTweener::TWEQ_BACK, CDBTweener::TWEA_INOUT, 2.f, &newLogoY, 0.0f);
first = true;
pressFactor = 0.2;
transition = false;
check = false;
sm.init(sf::Vector2f(WIDTH, HEIGHT));
rt.create(WIDTH, HEIGHT);
MusicManager::instance().playMusicFast("low");
selection = 1;
};
示例6: main
int main()
{
//Initalize Variables and Settings
const sf::Vector2i screenDimensions(800, 600);
FloatRect playerMoveSpace = sf::FloatRect(100, 100, screenDimensions.x - 100, screenDimensions.y - 320);
RenderWindow window(VideoMode(screenDimensions.x, screenDimensions.y), "Donkey Island", Style::Titlebar | Style::Close);
window.setFramerateLimit(60);
CircleShape shape(100.f);
shape.setFillColor(Color::Green);
Texture MenuBGTex;
Sprite MenuBackground;
Texture PlayerTex;
AnimatedSprite PlayerImage;
sf::Time actionTimer;
int loadedLevelIndex = 0;
GameScene* levels[] = { new LakeGrass(), new flower(), new House() };
GameScene* loadedLevel = levels[loadedLevelIndex];
tinyxml2::XMLElement* levelElement = NULL;
static bool dragging = false;
sf::Vector2f Target1;
Inventory::item *draggeditem = NULL;
bool clicked = false;
if (MenuBGTex.loadFromFile("resources/menubackground.jpg")) {
MenuBackground.setTexture(MenuBGTex);
MenuBackground.setPosition(0.0f, 460.0f);
}
// load a new inventory. The inventory is kept across scenes.
Inventory* playerInventory = new Inventory();
// load a new quest journal. Each level, this variable is recreated with the right quests for that current level
Quests* playerQuests = new Quests(loadedLevel);
if (!PlayerTex.loadFromFile("resources/donkeyMovement.png")) {
std::cout << "Failed to load player spritesheet!" << std::endl;
return 1;
}
Animation walkingAnimationRight;
walkingAnimationRight.setSpriteSheet(PlayerTex);
walkingAnimationRight.addFrame(sf::IntRect(200, 0, 200, 200));
walkingAnimationRight.addFrame(sf::IntRect(400, 0, 200, 200));
walkingAnimationRight.addFrame(sf::IntRect(600, 0, 200, 200));
walkingAnimationRight.addFrame(sf::IntRect(0, 0, 200, 200));
Animation walkingAnimationLeft;
walkingAnimationLeft.setSpriteSheet(PlayerTex);
walkingAnimationLeft.addFrame(sf::IntRect(200, 200, 200, 200));
walkingAnimationLeft.addFrame(sf::IntRect(400, 200, 200, 200));
walkingAnimationLeft.addFrame(sf::IntRect(600, 200, 200, 200));
walkingAnimationLeft.addFrame(sf::IntRect(0, 200, 200, 200));
Animation walkingAnimationIdle;
walkingAnimationIdle.setSpriteSheet(PlayerTex);
walkingAnimationIdle.addFrame(sf::IntRect(200, 400, 200, 200));
walkingAnimationIdle.addFrame(sf::IntRect(400, 400, 200, 200));
walkingAnimationIdle.addFrame(sf::IntRect(600, 400, 200, 200));
walkingAnimationIdle.addFrame(sf::IntRect(0, 400, 200, 200));
Animation* currentAnimation = &walkingAnimationLeft;
PlayerImage = AnimatedSprite(sf::seconds(0.1), true, false);
PlayerImage.setPosition(sf::Vector2f(screenDimensions / 3));
sf::Clock frameClock;
float speed = 160.f;
bool noKeyWasPressed = true;
// ------------------------
// Initialization ends here
// Our GAMELOOP starts here
while (window.isOpen()) {
Event event;
while (window.pollEvent(event)) {
if (event.type == Event::Closed) {
window.close();
}
if (event.type == Event::MouseButtonReleased) {
playerInventory->refreshItems();
dragging = false;
clicked = false;
//.........这里部分代码省略.........