本文整理汇总了C++中AnimatedSprite类的典型用法代码示例。如果您正苦于以下问题:C++ AnimatedSprite类的具体用法?C++ AnimatedSprite怎么用?C++ AnimatedSprite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AnimatedSprite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void Senario::update(float time)
{
if(animatedStringList != NULL)
{
for (int i = 0; i < animatedStringList->count(); i++)
{
AnimatedString* as = (AnimatedString*) animatedStringList->objectAtIndex(i);
as->update(time);
}
}
if(animatedSpriteList != NULL)
{
for (int i = 0; i < animatedSpriteList->count(); i++)
{
AnimatedSprite* as = (AnimatedSprite*) animatedSpriteList->objectAtIndex(i);
as->update(time);
}
}
if(animatedDialogueList != NULL)
{
for (int i = 0; i < animatedDialogueList->count(); i++)
{
AnimatedDialogue* ad = (AnimatedDialogue*) animatedDialogueList->objectAtIndex(i);
ad->update(time);
}
}
}
示例2: 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;
}
示例3: AnimatedSprite
AnimatedSprite* AnimatedSprite::create(std::string filepath, int columns, int rows)
{
AnimatedSprite* animatedsprite = new AnimatedSprite();
animatedsprite->init(filepath, columns, rows);
animatedsprite->autorelease();
return animatedsprite;
}
示例4: _find_anim_sprites
static void _find_anim_sprites(Node *p_node, List<Node *> *r_nodes, Ref<SpriteFrames> p_sfames) {
Node *edited = EditorNode::get_singleton()->get_edited_scene();
if (!edited)
return;
if (p_node != edited && p_node->get_owner() != edited)
return;
{
AnimatedSprite *as = p_node->cast_to<AnimatedSprite>();
if (as && as->get_sprite_frames() == p_sfames) {
r_nodes->push_back(p_node);
}
}
{
AnimatedSprite3D *as = p_node->cast_to<AnimatedSprite3D>();
if (as && as->get_sprite_frames() == p_sfames) {
r_nodes->push_back(p_node);
}
}
for (int i = 0; i < p_node->get_child_count(); i++) {
_find_anim_sprites(p_node->get_child(i), r_nodes, p_sfames);
}
}
示例5: there
/*
update - This method should be called once per frame. It updates
both the sprites and the game world. Note that even though the game
world is for static data, should the user wish to put anything dynamic
there (like a non-collidable moving layer), the updateWorld method
is called.
*/
void GameStateManager::update(Game *game)
{
game->getGameRules()->spawnEnemies(game);
spriteManager->update(game);
world.update(game);
physics.update(game);
AnimatedSprite *p = spriteManager->getPlayer();
PhysicalProperties *pp = p->getPhysicalProperties();
float pVelX = pp->getVelocityX();
float pVelY = pp->getVelocityY();
//VIEWPORT SCOPING
/*Viewport *vp = game->getGUI()->getViewport();
if(pVelX < 0
&& (pp->round(pp->getX() - vp->getViewportX())) < vp->getViewportWidth()/3)
{
vp->setScrollSpeedX(pVelX);
if(vp->getViewportX() == 0)
vp->setScrollSpeedX(0);
}
else if(pVelX > 0
&& (pp->round(pp->getX() - vp->getViewportX())) > (vp->getViewportWidth()/3*2))
{
vp->setScrollSpeedX(pVelX);
if(vp->getViewportX()+vp->getViewportWidth() == world.getWorldWidth())
vp->setScrollSpeedX(0);
}
else
{
vp->setScrollSpeedX(0);
}
if(pVelY < 0
&& (pp->round(pp->getY() - vp->getViewportY())) < vp->getViewportHeight()/3)
{
vp->setScrollSpeedY(pVelY);
if(vp->getViewportY() == 0)
vp->setScrollSpeedY(0);
}
else if(pVelY > 0
&& (pp->round(pp->getY() - vp->getViewportY())) > (vp->getViewportHeight()/3*2))
{
vp->setScrollSpeedY(pVelY);
if(vp->getViewportY()+vp->getViewportHeight() == world.getWorldHeight())
vp->setScrollSpeedY(0);
}
else
{
vp->setScrollSpeedY(0);
}
vp->moveViewport( vp->getScrollSpeedX(),
vp->getScrollSpeedY(),
world.getWorldWidth(),
world.getWorldHeight());*/
}
示例6: AnimatedSprite
//static
AnimatedSprite* AnimatedSprite::create( AnimationLogic* animLogic, JsonValueRef spriteFrames )
{
AnimatedSprite* sprite = new AnimatedSprite();
sprite->init(animLogic, spriteFrames);
sprite->autorelease();
return sprite;
}
示例7: AnimatedSprite
AnimatedSprite* ResourceManager::get_sprite(string request, string animation, int sprite_width, int sprite_height){
AnimatedSprite* sprite = new AnimatedSprite();
Animation* sprite_animation = get_animation(request, animation, sprite_width, sprite_height);
sprite->set_animation(sprite_animation);
return sprite;
}
示例8: if
void ScienceMouseEventHandler::handleMousePressEvent(Game *game, int mouseX, int mouseY)
{
if (game->getGSM()->isGameInProgress())
{
Viewport *viewport = game->getGUI()->getViewport();
// DETERMINE WHERE ON THE MAP WE HAVE CLICKED
int worldCoordinateX = mouseX + viewport->getViewportX();
int worldCoordinateY = mouseY + viewport->getViewportY();
// NOW LET'S SEE IF THERE IS A SPRITE THERE
GameStateManager *gsm = game->getGSM();
SpriteManager *spriteManager = gsm->getSpriteManager();
// IF THERE IS NO SELECTED SPRITE LOOK FOR ONE
if (!(spriteManager->getIsSpriteSelected()))
{
// IF THIS DOES NOT RETURN NULL THEN YOU FOUND A SPRITE AT THAT LOCATION
if((spriteManager->getSpriteAt(worldCoordinateX, worldCoordinateY) != NULL))
{
AnimatedSprite *selected = spriteManager->getSpriteAt(worldCoordinateX, worldCoordinateY);
spriteManager->setIsSpriteSelected(true);
}
}
else if (spriteManager->getSelectedSprite() != NULL)
{
// MOVE A SPRITE IN A DESIRED DIRECTION
AnimatedSprite *selected = spriteManager->getSelectedSprite();
PhysicalProperties *pp = selected->getPhysicalProperties();
float spriteX = pp->getX();
float spriteY = pp->getY();
//IF A SPRITE IS WHERE YOU WANT IT THEN STOP IT
if (((spriteX > worldCoordinateX - 64) && (spriteX < worldCoordinateX + 64)) && (spriteY > worldCoordinateY - 64) && (spriteY < worldCoordinateY + 64))
{
pp->setVelocity(0, 0);
}
else
{
float deltaX = worldCoordinateX - spriteX;
float deltaY = worldCoordinateY - spriteY;
float hyp = sqrtf((deltaX * deltaX) + (deltaY * deltaY));
pp->setVelocity((deltaX / hyp) * 3, (deltaY / hyp) * 3);
}
spriteManager->setIsSpriteSelected(false);
// GridPathfinder *pathfinder = spriteManager->getPathfinder();
// pathfinder->mapPath(selected, (float)worldCoordinateX, (float)worldCoordinateY);
// gsm->setSpriteSelected(false, selected);
}
else
{
spriteManager->setIsSpriteSelected(false);
}
}
}
示例9:
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;
}
}
示例10: Explosion
void
Game::SpawnExplosion(int x, int y)
{
Explosion* explosion = new Explosion();
explosion->SetPositionX(x - 10);
explosion->SetPositionY(y - 10);
AnimatedSprite* exploding = m_pBackBuffer->CreateAnimatedSprite("assets\\explosion.png");
exploding->SetLooping(false);
exploding->SetFrameWidth(64);
exploding->SetFrameSpeed(0.05);
exploding->AddFrame(0);
exploding->AddFrame(64);
exploding->AddFrame(128);
exploding->AddFrame(192);
exploding->AddFrame(256);
explosion->Initialise(exploding);
Explosions.push_back(explosion);
}
示例11: assert
AnimatedSprite*
BackBuffer::CreateAnimatedSprite(const char* pcFilename)
{
assert(m_pTextureManager);
Texture* pTexture = m_pTextureManager->GetTexture(pcFilename);
AnimatedSprite* pSprite = new AnimatedSprite();
if (!pSprite->Initialise(*pTexture))
{
LogManager::GetInstance().Log("Sprite Failed to Create!");
}
return (pSprite);
}
示例12: ensureSize
void Being::setSprite(unsigned int slot, int id, const std::string &color,
bool isWeapon)
{
if (slot >= size())
ensureSize(slot + 1);
if (slot >= mSpriteIDs.size())
mSpriteIDs.resize(slot + 1);
if (slot >= mSpriteColors.size())
mSpriteColors.resize(slot + 1);
// id = 0 means unequip
if (id == 0)
{
removeSprite(slot);
if (isWeapon)
mEquippedWeapon = 0;
}
else
{
std::string filename = itemDb->get(id).getSprite(mGender);
AnimatedSprite *equipmentSprite = 0;
if (!filename.empty())
{
if (!color.empty())
filename += "|" + color;
equipmentSprite = AnimatedSprite::load(
paths.getStringValue("sprites") + filename);
}
if (equipmentSprite)
equipmentSprite->setDirection(getSpriteDirection());
CompoundSprite::setSprite(slot, equipmentSprite);
if (isWeapon)
mEquippedWeapon = &itemDb->get(id);
setAction(mAction);
}
mSpriteIDs[slot] = id;
mSpriteColors[slot] = color;
}
示例13: handleDownstreamDamageZoneCreationEvent
bool handleDownstreamDamageZoneCreationEvent(
const DamageZoneCreationEvent& e,
const TeamMembership* actorTeamMembership,
const irr::core::aabbox3df& actorHitBox,
AnimatedSprite& actorSprite)
{
// damage only happens if you're on different teams
if (actorTeamMembership->getTeam() != e.getInflictorMembership()->getTeam())
{
if (actorHitBox.intersectsWithBox(e.getDamageZoneBounds()))
{
GameApp::getSingleton().getSoundEngine()->play2D("../../../art/punch.wav");
actorSprite.toggleFlipHorizontal();
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
示例14: assert
void Player::setSprite(unsigned int slot, int id, const std::string &color)
{
assert(slot >= BASE_SPRITE && slot < VECTOREND_SPRITE);
// id = 0 means unequip
if (id == 0)
{
delete mSprites[slot];
mSprites[slot] = NULL;
#ifdef EATHENA_SUPPORT
if (slot == WEAPON_SPRITE)
mEquippedWeapon = NULL;
// if (slot == )
#endif
}
else
{
std::string filename = ItemDB::get(id).getSprite(mGender);
AnimatedSprite *equipmentSprite = NULL;
if (!filename.empty())
{
if (!color.empty())
filename += "|" + color;
equipmentSprite = AnimatedSprite::load("graphics/sprites/" +
filename);
}
if (equipmentSprite)
equipmentSprite->setDirection(getSpriteDirection());
delete mSprites[slot];
mSprites[slot] = equipmentSprite;
if (slot == WEAPON_SPRITE)
mEquippedWeapon = &ItemDB::get(id);
setAction(mAction);
}
mSpriteIDs[slot] = id;
mSpriteColors[slot] = color;
}
示例15: DrawAnimatedSprite
void BackBuffer::DrawAnimatedSprite(AnimatedSprite& sprite, int x, int width)
{
SDL_Rect dest;
dest.x = sprite.GetX();
dest.y = sprite.GetY();
dest.w = width;
dest.h = sprite.GetHeight();
SDL_Rect* f = new SDL_Rect;
//location of animation frame
f->x = x;
f->y = 0;
f->w = width;
f->h = sprite.GetHeight();
SDL_RenderCopy(m_pRenderer, sprite.GetTexture()->GetTexture(), f, &dest);
}