Ejemplo n.º 1
0
void Bubble::init(float px, float py, AnimatedSpriteType *sprite){
	setHitPoints(1);
	setDamage(SEED_DAMAGE);
	setSpriteType(sprite);
	setAlpha(255);
	setCurrentState(IDLE_LEFT);
	PhysicalProperties *fireballProps = getPhysicalProperties();
	pp.setX(px);
	pp.setY(py);
	pp.setVelocity(0.0f, 0.0f);
	pp.setAccelerationX(0);
	pp.setAccelerationY(0);
	setOnTileThisFrame(false);
	setOnTileLastFrame(false);
	affixTightAABBBoundingVolume();
}
/*
	changeFrame - This method allows for the changing of an image in an 
	animation sequence for a given animation state.
*/
void AnimatedSprite::changeFrame()
{
	// RESET THE COUNTER
	animationCounter = 0;

	// REMEMBER, WE COUNT BY 2s
	frameIndex += 2;

	// GO BACK TO FIRST INDEX IF NECESSARY
	if (frameIndex == spriteType->getSequenceSize(currentState))
	{
		frameIndex = 0;
		if (currentState.compare(L"DYING") == 0)
		{
			setCurrentState(L"DEAD");
			getPhysicalProperties()->setVelocity(0, 0);
			deadTimer = 0;
		}
		else if (currentState.compare(L"DEAD") == 0)
		{
			deadTimer++;
		}
	}
}