当前位置: 首页>>代码示例>>C++>>正文


C++ AnimatedSprite类代码示例

本文整理汇总了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);
        }
    }
}
开发者ID:keyor,项目名称:Nanhua,代码行数:29,代码来源:Senario.cpp

示例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;
}
开发者ID:deipfei,项目名称:MacPan,代码行数:32,代码来源:pacman.cpp

示例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;
}
开发者ID:hehehoho1,项目名称:final-thesis,代码行数:7,代码来源:AnimatedSprite.cpp

示例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);
	}
}
开发者ID:allkhor,项目名称:godot,代码行数:26,代码来源:sprite_frames_editor_plugin.cpp

示例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());*/
}
开发者ID:Esaft,项目名称:esaft-cse380,代码行数:66,代码来源:GameStateManager.cpp

示例6: AnimatedSprite

//static 
AnimatedSprite* AnimatedSprite::create( AnimationLogic* animLogic, JsonValueRef spriteFrames  )
{
	AnimatedSprite* sprite = new AnimatedSprite();
	sprite->init(animLogic, spriteFrames);
	sprite->autorelease();
	return sprite;

}
开发者ID:keless,项目名称:FuzzPop,代码行数:9,代码来源:ZZAnimatedSprite.cpp

示例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;
}
开发者ID:XtremePrime,项目名称:LudumDare30,代码行数:8,代码来源:resourcemanager.cpp

示例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);
		}
	}
}
开发者ID:kpropper,项目名称:Science,代码行数:58,代码来源:ScienceMouseEventHandler.cpp

示例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;
    }
}
开发者ID:mekolat,项目名称:elektrogamesvn,代码行数:14,代码来源:statuseffect.cpp

示例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);
}
开发者ID:Sisky,项目名称:Game-Programming,代码行数:26,代码来源:game.cpp

示例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);
}
开发者ID:Athlos,项目名称:Circuit-Collector,代码行数:15,代码来源:backbuffer.cpp

示例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;
}
开发者ID:Ablu,项目名称:mana,代码行数:48,代码来源:being.cpp

示例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;
	}
}
开发者ID:UVicGameDev,项目名称:viking,代码行数:26,代码来源:CombatSceneActorHelper.cpp

示例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;
}
开发者ID:mekolat,项目名称:elektrogamesvn,代码行数:46,代码来源:player.cpp

示例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);
}
开发者ID:Athlos,项目名称:Circuit-Collector,代码行数:18,代码来源:backbuffer.cpp


注:本文中的AnimatedSprite类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。