Пример #1
0
void UnstableTile::loadAnimation(int skinNr) {
	m_isCollidable = true;

	Animation* idleAnimation = new Animation(sf::seconds(10.f));
	idleAnimation->setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_tile_unstable));
	idleAnimation->addFrame(sf::IntRect(BORDER, BORDER + ((skinNr - 1) * (TILE_SIZE + 2 * BORDER)), TILE_SIZE, TILE_SIZE));

	addAnimation(GameObjectState::Idle, idleAnimation);

	Animation* tremblingAnimation = new Animation(sf::seconds(0.1f));
	tremblingAnimation->setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_tile_unstable));
	tremblingAnimation->addFrame(sf::IntRect(BORDER + 1 * (2 * BORDER + TILE_SIZE), BORDER + ((skinNr - 1) * (TILE_SIZE + 2 * BORDER)), TILE_SIZE, TILE_SIZE));
	tremblingAnimation->addFrame(sf::IntRect(BORDER + 2 * (2 * BORDER + TILE_SIZE), BORDER + ((skinNr - 1) * (TILE_SIZE + 2 * BORDER)), TILE_SIZE, TILE_SIZE));

	addAnimation(GameObjectState::Trembling, tremblingAnimation);

	Animation* crumblingAnimation = new Animation();
	crumblingAnimation->setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_tile_destructible));
	for (int i = 1; i < 5; i++) {
		crumblingAnimation->addFrame(sf::IntRect(
			BORDER + i * (2 * BORDER + TILE_SIZE),
			BORDER,
			TILE_SIZE,
			TILE_SIZE));
	}

	addAnimation(GameObjectState::Crumbling, crumblingAnimation);

	// initial values
	m_state = GameObjectState::Idle;
	setCurrentAnimation(getAnimation(GameObjectState::Idle), false);
	playCurrentAnimation(true);
}
Пример #2
0
	SmashBall::SmashBall(float x1, float y1) : Item(x1,y1, 40000,TYPE_WIELD)
	{
		moveTime = 0;
		speed = 1;
		hittable = true;
		unHittableTime = 0;
		health = 10;
		
		active = true;
		
		itemNo = Global::ITEM_SMASHBALL;

		readyFire = null;
		
		Animation*anim;
		
		anim = new Animation("normal", 5, 8, 1);
		anim->addFrame("Images/Game/Items/SmashBall/smashball.png");
		addAnimation(anim);
		
		anim = new Animation("hit", 6, 2, 1);
		anim->addFrame("Images/Game/Items/SmashBall/smashball_hit.png");
		addAnimation(anim);
		
		addFileResource("Images/Game/Items/SmashBall/finalsmash_fire.png");
		
		changeAnimation("normal",FORWARD);
		
		ignoreGoThroughPlatforms(true);
		setSolid(true);
		canBeCarried(false);
	}
Пример #3
0
void main()
{
	sfw::initContext(800, 600, "NSFW Draw");
	sfw::setBackgroundColor(BLACK);	


	// Now I'm using the loadTexture from AssetLibrary! Notice how I Get to name it now.
	// The name lets me easily refer to it later!
	loadTexture("Explosion", "../res/explosion.png", 5, 3); // so this is an explosion sprite sheet. TLDR WE WILL MAKE DINOSAURS EXPLODE!
	addAnimation("Explosion", "BOOM", {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14});
	addAnimation("Explosion", "NOTVERYBOOM", { 0,1 });

	//MenuState menu;

	// All of the logic for our game goes here now!
	GameState game;

	while (sfw::stepContext())
	{
		//switch ()
		//{
		//case MENU:
		//	menu.update();
		//	menu.draw();
		//case GAME:
			game.update(); // Do the thing!
			game.draw();   // Draw it!	    
		//}
	}

	sfw::termContext();
}
Пример #4
0
	RayGun::Ray::Ray(byte playerNo, float x1, float y1) : Projectile(playerNo, x1, y1)
	{
		Animation*anim;
			
		anim = new Animation("left",1,"Images/Game/Items/RayGun/ray.png");
		addAnimation(anim);
			
		anim = new Animation("right",1,"Images/Game/Items/RayGun/ray.png");
		anim->mirror(true);
		addAnimation(anim);
		
		switch(itemdir)
		{
			case Player::LEFT:
			changeAnimation("left",FORWARD);
			xvelocity = -6;
			break;
				
			case Player::RIGHT:
			changeAnimation("right",FORWARD);
			xvelocity = 6;
			break;
		}
			
		startX = x;
	}
Пример #5
0
Robot_Soldier::Robot_Soldier(const float scale) {
  this->resolution_scale = scale;
  hitBoxWidth = 15 * scale;
  hitBoxHeight = 31 * scale;
  setScale(resolution_scale);
  maxWalkSpeed = 100 / 2 * scale;
  maxFlySpeed = 270 / 2 * scale;
  groundAcceleration = 8 / 2 * scale;
  groundDeaccleration = 0.65 / 2 * scale;
  player_sprite = cocos2d::Sprite::create();
  player_sprite->setAnchorPoint(Point(0.5, 0));
  this->addChild(player_sprite);
  hsp = 60;
  right = true;
  hitBoxHeight = 32;
  hitBoxWidth = 32;
  addHitboxToSprite();
  //drawHitbox();
  this->schedule(CC_SCHEDULE_SELECTOR(Robot_Soldier::updateAI), 0.5);
  AI_STATE = AI_PATROLLING;
  HP = 3;
  check_for_gravity = true;
  this->visionRange *= 2;
  idString = "enemy";
  spriteFrameCache = spriteFrameCache->getInstance();
  animationCache = animationCache->getInstance();
  spriteFrameCache->addSpriteFramesWithFile("Robot_Soldier.plist");
  addAnimation("Robot_Soldier ", "robSol_WalkRight", 1, 4, 0.2f);
  addAnimation("Robot_Soldier ", "robSol_WalkLeft", 1, 4, 0.2f);
  addAnimation("Robot_Soldier ", "robSol_Dead", 5, 6, 0.3f);
  hsp = maxWalkSpeed;
  HP = 1;
  moveWhenOutsideOfScreen = true;
}
Пример #6
0
bool TankObject::setupAnimation() {
  // SETUP ANIMATIONS
  
  SpriteFrameCache::getInstance()->addSpriteFramesWithFile("tank.plist");
  addAnimation("tank", "tank_idle", 1, 4, 0.18f);
  addAnimation("tank", "tank_dead", 1, 4, 0.07f);
  return true;
}
Пример #7
0
bool FishObject::setupAnimation() {
  // SETUP ANIMATIONS
  
  
  SpriteFrameCache::getInstance()->addSpriteFramesWithFile("fish.plist");
  addAnimation("fish", "fish_idle", 1, 4, 0.25f);
  addAnimation("fish", "fish_dead", 3, 3, 1.f);
  return true;
}
Пример #8
0
bool ZombieObject::setupAnimation() {
  // SETUP ANIMATIONS
  
  SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zombie_and_snail.plist");
  addAnimation("zombie", "zombie_idle", 1, 1, 0.3f);
  addAnimation("zombie", "zombie_walk", 1, 8, 0.2f);
  addAnimation("zombie", "zombie_dead", 3, 3, 0.3f);
  return true;
}
Пример #9
0
void LevelMainCharacter::load()
{
	setBoundingBox(sf::FloatRect(0.f, 0.f, 30.f, 100.f));
	setSpriteOffset(sf::Vector2f(-25.f, -20.f));

	Animation walkingAnimation;
	walkingAnimation.setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_mainChar));
	walkingAnimation.addFrame(sf::IntRect(0, 0, 80, 120));
	walkingAnimation.addFrame(sf::IntRect(80, 0, 80, 120));
	walkingAnimation.addFrame(sf::IntRect(160, 0, 80, 120));
	walkingAnimation.addFrame(sf::IntRect(240, 0, 80, 120));
	walkingAnimation.addFrame(sf::IntRect(320, 0, 80, 120));
	walkingAnimation.addFrame(sf::IntRect(400, 0, 80, 120));
	walkingAnimation.addFrame(sf::IntRect(480, 0, 80, 120));
	walkingAnimation.addFrame(sf::IntRect(560, 0, 80, 120));

	addAnimation(GameObjectState::Walking, walkingAnimation);

	Animation idleAnimation;
	idleAnimation.setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_mainChar));
	idleAnimation.addFrame(sf::IntRect(640, 0, 80, 120));

	addAnimation(GameObjectState::Idle, idleAnimation);

	Animation jumpingAnimation;
	jumpingAnimation.setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_mainChar));
	jumpingAnimation.addFrame(sf::IntRect(720, 0, 80, 120));

	addAnimation(GameObjectState::Jumping, jumpingAnimation);

	Animation fightingAnimation;
	fightingAnimation.setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_mainChar));
	fightingAnimation.addFrame(sf::IntRect(800, 0, 80, 120));
	fightingAnimation.addFrame(sf::IntRect(880, 0, 80, 120));
	fightingAnimation.addFrame(sf::IntRect(960, 0, 80, 120));
	fightingAnimation.addFrame(sf::IntRect(1040, 0, 80, 120));
	fightingAnimation.addFrame(sf::IntRect(1040, 0, 80, 120));

	addAnimation(GameObjectState::Fighting, fightingAnimation);

	Animation deadAnimation;
	deadAnimation.setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_mainChar));
	deadAnimation.addFrame(sf::IntRect(1120, 0, 80, 120));

	addAnimation(GameObjectState::Dead, deadAnimation);

	setFrameTime(sf::seconds(0.07f));

	// initial values
	m_state = GameObjectState::Idle;
	m_isFacingRight = true;
	setCurrentAnimation(getAnimation(m_state), !m_isFacingRight);
	playCurrentAnimation(true);

	setDebugBoundingBox(sf::Color::White);
}
Пример #10
0
int main()
{
	//Remove Console Window
	FreeConsole();

	//Render Game Window
	sfw::initContext(800, 800, "Basic");

	//Load Textures from File
	loadTexture("Background", "./Textures/Dungeon.png", 1, 1);
	loadTexture("Title",      "./Textures/title.png",   1, 1);
	loadTexture("dKnight",    "./Textures/dKnight.png", 4, 4);
	loadTexture("spear",      "./Textures/spear.PNG",   8, 8);
	loadTexture("slime",      "./Textures/Slime.png",   6, 4);
	loadTexture("press",      "./Textures/pressF.png",  1, 1);
	loadTexture("pressA",     "./Textures/pressA.png",  1, 1);
	loadTexture("win",        "./Textures/win.png",     1, 1);
	loadTexture("lose",       "./Textures/lose.png",    1, 1);
	loadTexture("move",       "./Textures/moveText.png",1, 1);
	loadTexture("fire",       "./Textures/fireText.png",1, 1);
	loadTexture("font",       "./Textures/fontmap.png", 16, 16);

	//Set Animations
	addAnimation("dKnight",   "walkLeft",  { 4, 5, 6, 7 });
	addAnimation("dKnight",   "walkRight", { 8, 9, 10, 11 });
	addAnimation("dKnight",   "walkUp",    { 12, 13, 14, 15 });
	addAnimation("dKnight",   "walkDown",  { 0, 1, 2, 3 });
	addAnimation("slime",     "slideUp",   { 0, 1, 2, 3 });

	//Instantiate necessary Classes
	GameState game;
	STATE state = Splash;
	
	//Set Main Game States and continue looping until exited
	while (sfw::stepContext())
	{
		switch (state)
		{
		case Splash:
			state = game.splashScreen(); break;
		case Main:
			return Game;
		case Game:
			game.update();
			state = game.draw(); break;
		case Win:
			state = game.win(); break;
		case Lose:
			state = game.lose(); break;
		}
	}
	sfw::termContext();
	return 0;
}
Пример #11
0
BossSpider::BossSpider(float x, float y)
:Enemy(x, y, 56.0f, 41.0f)
{
	setImage("spider.png");
	walk_speed = 100.0f;

	dying = false;
	life = 5;

	setDrawOffset(32, 63);
	setFrameSize(64, 64);
	lastShot = 0;
	shootInterval = 0.5f;
	time = 0;

	patrolInterval = 1.5f;
	patrolTime = 0;

	Animation * tmp;

	//pick a random death sound
	int sound_num = rand() % 19;
	sound_num += 1;
	std::string s;
	std::stringstream out;
	out << sound_num;
	s = out.str();

	std::string sound_file = s + "-BugSplat.ogg";
	//cout << sound_file;
	fireSound = soundCache[sound_file];
	shape->u = 0.1f;

	tmp = addAnimation("walk");
	tmp->addFrame(0, .2f);
	tmp->addFrame(1, .2f);
	tmp->addFrame(2, .2f);
	tmp->addFrame(4, .2f);
	tmp->addFrame(5, .2f);
	tmp->setDoLoop(true);

	tmp = addAnimation("die");
	tmp->addFrame(8, .2f);
	tmp->addFrame(9, .2f);
	tmp->addFrame(10, .2f);
	tmp->addFrame(11, .2f);

	tmp = addAnimation("hurt");
	tmp->addFrame(0, 0.07f);

	setCurrentAnimation("walk");
}
Пример #12
0
	void initialize()
	{
		int i = 0;
		for(i = 0; i < properties.getIdleAnimationAmount(); ++i)
			addAnimation(idles, properties.getIdleAnimationName(i), properties.getIdleAnimation(i));

		for(i = 0; i < properties.getExpressionAnimationAmount(); ++i)
			addAnimation(expressions, properties.getExpressionAnimationName(i), properties.getExpressionAnimation(i));

		buildAmplitudeArray();

		idleFadeTime = properties.getPropertyValue(LipsyncProperties::IdleFadeTime);
		expressionFadeTime = properties.getPropertyValue(LipsyncProperties::ExpressionFadeTime);
		sampleRate = properties.getPropertyValue(LipsyncProperties::SampleRate);
	}
Пример #13
0
	HeartContainer::HeartContainer(float x1, float y1) : Item(x1, y1, 200, TYPE_FOOD)
	{
		weight = 0.8f;
		accelerateGravity(false);
		
		itemNo = Global::ITEM_HEARTCONTAINER;
		
		available = true;
		
		addAnimation(new Animation("normal",1,"Images/Game/Items/HeartContainer/heart_container.png"));
		Animation*anim = new Animation("sparkle",8,4,1);
		anim->addFrame("Images/Game/Items/HeartContainer/sparkle.png");
		addAnimation(anim);
		changeAnimation("normal",FORWARD);
	}
Пример #14
0
void FireRatEnemy::load()
{
	setBoundingBox(sf::FloatRect(0.f, 0.f, 40.f, 30.f));
	setSpriteOffset(sf::Vector2f(-5.f, -20.f));

	Animation walkingAnimation;
	walkingAnimation.setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_enemy_firerat));
	walkingAnimation.addFrame(sf::IntRect(0, 0, 50, 50));
	walkingAnimation.addFrame(sf::IntRect(50, 0, 50, 50));
	walkingAnimation.addFrame(sf::IntRect(100, 0, 50, 50));
	walkingAnimation.addFrame(sf::IntRect(50, 0, 50, 50));

	addAnimation(GameObjectState::Walking, walkingAnimation);

	Animation idleAnimation;
	idleAnimation.setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_enemy_firerat));
	idleAnimation.addFrame(sf::IntRect(50, 0, 50, 50));
	idleAnimation.addFrame(sf::IntRect(300, 0, 50, 50));

	addAnimation(GameObjectState::Idle, idleAnimation);

	Animation jumpingAnimation;
	jumpingAnimation.setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_enemy_firerat));
	jumpingAnimation.addFrame(sf::IntRect(150, 0, 50, 50));

	addAnimation(GameObjectState::Jumping, jumpingAnimation);

	Animation fightingAnimation;
	fightingAnimation.setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_enemy_firerat));
	fightingAnimation.addFrame(sf::IntRect(200, 0, 50, 50));
	fightingAnimation.addFrame(sf::IntRect(250, 0, 50, 50));

	addAnimation(GameObjectState::Fighting, fightingAnimation);

	Animation deadAnimation;
	deadAnimation.setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_enemy_firerat));
	deadAnimation.addFrame(sf::IntRect(350, 0, 50, 50));

	addAnimation(GameObjectState::Dead, deadAnimation);

	setFrameTime(sf::seconds(0.08f));

	// initial values
	m_state = GameObjectState::Idle;
	m_isFacingRight = true;
	setCurrentAnimation(getAnimation(m_state), !m_isFacingRight);
	playCurrentAnimation(true);
}
// ***************************************************************************
bool CAnimationSet::loadFromFiles(const std::string &path, bool recurse /* = true*/, const char *ext /*= "anim"*/, bool wantWarningMessage /*= true*/)
{
	bool everythingOk = true;
	std::vector<std::string> anims;
	NLMISC::CPath::getPathContent(path, recurse, false, true, anims);
	for (uint k = 0; k < anims.size(); ++k)
	{
		std::string fileExt = NLMISC::CFile::getExtension(anims[k]);
		if (fileExt == ext) // an animation file ?
		{
			try
			{
				NLMISC::CIFile	iFile;
				iFile.open(anims[k]);
				std::auto_ptr<CAnimation> anim(new CAnimation);
				anim->serial(iFile);
				addAnimation(NLMISC::CFile::getFilenameWithoutExtension(anims[k]).c_str(), anim.release());
				iFile.close();

			}
			catch (NLMISC::EStream &e)
			{
				if (wantWarningMessage)
				{
					nlinfo("Unable to load an automatic animation : %s", e.what());
				}
				everythingOk = false;
			}
		}
	}
	build();
	return everythingOk;
}
Пример #16
0
bool ScrollAnimator::sendAnimationToCompositor() {
  if (m_scrollableArea->shouldScrollOnMainThread())
    return false;

  std::unique_ptr<CompositorAnimation> animation = CompositorAnimation::create(
      *m_animationCurve, CompositorTargetProperty::SCROLL_OFFSET, 0, 0);
  // Being here means that either there is an animation that needs
  // to be sent to the compositor, or an animation that needs to
  // be updated (a new scroll event before the previous animation
  // is finished). In either case, the start time is when the
  // first animation was initiated. This re-targets the animation
  // using the current time on main thread.
  animation->setStartTime(m_startTime);

  int animationId = animation->id();
  int animationGroupId = animation->group();

  bool sentToCompositor = addAnimation(std::move(animation));
  if (sentToCompositor) {
    m_runState = RunState::RunningOnCompositor;
    m_compositorAnimationId = animationId;
    m_compositorAnimationGroupId = animationGroupId;
  }

  return sentToCompositor;
}
Пример #17
0
/**
* 函数介绍: init
* 作者:wa000
* 日期:2014
*/ 
bool PlayerBoom::init()
{
	addAnimation();
	this->initWithSpriteFrameName("boom(400,400)-run-1.png");
	_finished = 0;
	return true;
}
void VariableAnimationSignalTransition::setAnimation(QAbstractAnimation * p_anim)
{
	if (!p_anim)
		return;
	clearAnimations();
	addAnimation(p_anim);
}
Пример #19
0
void FlashSpell::load(const SpellData& data, LevelMovableGameObject* mob, const sf::Vector2f& target) {
	setSpriteOffset(sf::Vector2f(-10.f, 0.f));
	m_mob = mob;
	
	Animation* spellAnimation = new Animation(sf::milliseconds(200));
	spellAnimation->setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_spell_flash));
	spellAnimation->addFrame(sf::IntRect(0, 0, 120, 120));
	spellAnimation->addFrame(sf::IntRect(120, 0, 120, 120));

	addAnimation(GameObjectState::Idle, spellAnimation);

	// initial values
	setCurrentAnimation(getAnimation(GameObjectState::Idle), false);
	playCurrentAnimation(true);
	
	Spell::load(data, mob, target);
	m_isFlashingRight = mob->isFacingRight();
	
	m_flashingTime = FLASHING_TIME;
	m_flashDuration = FLASH_DURATION;

	sf::Vector2f position(m_mob->getPosition());
	position.x += (m_mob->getBoundingBox()->width / 2.f);
	position.y += m_mob->getBoundingBox()->height - 20;
	position.x = m_isFlashingRight ? position.x - data.range : position.x + data.range;
	loadParticleSystem();
	m_posGenerator->center = position;
}
Пример #20
0
void Llama::preloadResources(){
    
    //Cache de sprites
    auto spriteFrameCache = SpriteFrameCache::getInstance();
    //Cache de animaciones
    auto animCache = AnimationCache::getInstance();
    
    //Si no estaba el spritesheet en la caché lo cargo
    
    if(!spriteFrameCache->getSpriteFrameByName("fuego1.png")) {
        spriteFrameCache->addSpriteFramesWithFile(OBJETOS_PLIST);
    }
    
    m_anim = Animation::create();
    
    m_anim->addSpriteFrame(spriteFrameCache->getSpriteFrameByName("fuego1.png"));
    m_anim->addSpriteFrame(spriteFrameCache->getSpriteFrameByName("fuego2.png"));
    
    m_anim->addSpriteFrame(spriteFrameCache->getSpriteFrameByName("fuego3.png"));
    m_anim->addSpriteFrame(spriteFrameCache->getSpriteFrameByName("fuego4.png"));
    m_anim->addSpriteFrame(spriteFrameCache->getSpriteFrameByName("fuego5.png"));
    m_anim->addSpriteFrame(spriteFrameCache->getSpriteFrameByName("fuego6.png"));
    m_anim->addSpriteFrame(spriteFrameCache->getSpriteFrameByName("fuego7.png"));
    m_anim->addSpriteFrame(spriteFrameCache->getSpriteFrameByName("fuego8.png"));
    
    m_anim->setDelayPerUnit(.15f);
    m_anim->retain();
    
    animCache->addAnimation(m_anim, "Llama");
    
}
Пример #21
0
	CharSelectScreen::CharIcon::CharIcon(int num, float x1, float y1, Animation*anim) : Actor(x1,y1)
	{
		setScale(1.8f);
		addAnimation(anim);
		changeAnimation(anim->name, FORWARD);
		this->num = num;
	}
Пример #22
0
void Layer::setValue(const string& key, const Variant& v, bool animated)
{
  bool setWithoutAnimation = false;
  if(animated)
  {
    auto pos = key2action.find(key);
    if(pos != key2action.end())
    {
      addAnimation(key, pos->second(key, v));
    }
    else
    {
      WOUT("no animation found for key: "<<key);
      setWithoutAnimation = true;
    }
  }
  
  if(!animated or setWithoutAnimation)
  {
    auto pos = key2setter.find(key);
    if(pos != key2setter.end())
    {
      pos->second(v);
    }
    else
    {
      WOUT("couldn't find setter for key '"<<key<<"'");
    }
  }
}
Пример #23
0
	CharSelectScreen::CharCoin::CharCoin(CharSelectScreen*screen,int num) : Actor(0,0)
	{
		drag = false;
		dragId = 0;
		this->screen = screen;
		Animation*anim;
		switch(num)
		{
			default:
			anim = new Animation("normal",1,"Images/Menus/CharacterSelect/coins/coin.png");
			break;
			
			case 1:
			anim = new Animation("normal",1,"Images/Menus/CharacterSelect/coins/coin1.png");
			break;
			
			case 2:
			anim = new Animation("normal",1,"Images/Menus/CharacterSelect/coins/coin2.png");
			break;
			
			case 3:
			anim = new Animation("normal",1,"Images/Menus/CharacterSelect/coins/coin3.png");
			break;
			
			case 4:
			anim = new Animation("normal",1,"Images/Menus/CharacterSelect/coins/coin4.png");
			break;
		}
		addAnimation(anim);
		changeAnimation("normal",FORWARD);
	}
 void SkeletonAnimationManager::_loadV1AnimationBin( BasicBinaryReader& reader,
                                                     const std::set< std::string >& animationsToLoad )
 {
     AnimationBinary::AnimationBinaryFileHeader header;
     reader.read( header );
     
     std::string curveCollection;
     reader.read( curveCollection );
     
     if( !curveCollection.empty() )
     {
         setCurveCollectionName( curveCollection );
         if( ! tempAnimationsToLoad.empty() )
         {
             CurveManager::getManager().loadCurveCollection( getCurveCollectionName(),
                                                             CallbackPtr(),
                                                             tempAnimationsToLoad );
         }
         else
         {
             CurveManager::getManager().loadCurveCollection(getCurveCollectionName());
         }
     }
     
     for( unsigned int i=0; i < header.mNumAnimations; ++i )
     {
         unsigned long long preAnimationOffset = reader.getCurrentOffset();
         std::string animationName;
         reader.read( animationName );
         
         unsigned int aniSize = reader.readUInt32();
         
         bool shouldAddAnimation = true;
         if( ! tempAnimationsToLoad.empty() )
         {
             if( tempAnimationsToLoad.find( animationName ) == tempAnimationsToLoad.end() )
             {
                 shouldAddAnimation = false;
             }
         }
         
         if( shouldAddAnimation )
         {
             Animation* ani =
                 Animation::createAnimationFromBinary( reader, animationName, mSkeleton );
             
             if( ani )
             {
                 addAnimation( ani );
             }
         }
         else
         {
             reader.seek( aniSize-(reader.getCurrentOffset()-preAnimationOffset),
                          BasicBinaryReader::SeekStart_Current );
         }
     }
     
     assert( reader.getBufferSize() == reader.getCurrentOffset() );
 }
Пример #25
0
void ProgrammaticScrollAnimator::updateCompositorAnimations() {
  if (m_runState == RunState::PostAnimationCleanup) {
    // No special cleanup, simply reset animation state. We have this state
    // here because the state machine is shared with ScrollAnimator which
    // has to do some cleanup that requires the compositing state to be clean.
    return resetAnimationState();
  }

  if (m_compositorAnimationId && m_runState != RunState::RunningOnCompositor) {
    // If the current run state is WaitingToSendToCompositor but we have a
    // non-zero compositor animation id, there's a currently running
    // compositor animation that needs to be removed here before the new
    // animation is added below.
    ASSERT(m_runState == RunState::WaitingToCancelOnCompositor ||
           m_runState == RunState::WaitingToSendToCompositor);

    removeAnimation();

    m_compositorAnimationId = 0;
    m_compositorAnimationGroupId = 0;
    if (m_runState == RunState::WaitingToCancelOnCompositor) {
      resetAnimationState();
      return;
    }
  }

  if (m_runState == RunState::WaitingToSendToCompositor) {
    if (!m_compositorAnimationAttachedToElementId)
      reattachCompositorPlayerIfNeeded(
          getScrollableArea()->compositorAnimationTimeline());

    bool sentToCompositor = false;

    if (!m_scrollableArea->shouldScrollOnMainThread()) {
      std::unique_ptr<CompositorAnimation> animation =
          CompositorAnimation::create(
              *m_animationCurve, CompositorTargetProperty::SCROLL_OFFSET, 0, 0);

      int animationId = animation->id();
      int animationGroupId = animation->group();

      if (addAnimation(std::move(animation))) {
        sentToCompositor = true;
        m_runState = RunState::RunningOnCompositor;
        m_compositorAnimationId = animationId;
        m_compositorAnimationGroupId = animationGroupId;
      }
    }

    if (!sentToCompositor) {
      m_runState = RunState::RunningOnMainThread;
      m_animationCurve->setInitialValue(
          compositorOffsetFromBlinkOffset(m_scrollableArea->getScrollOffset()));
      if (!m_scrollableArea->scheduleAnimation()) {
        notifyOffsetChanged(m_targetOffset);
        resetAnimationState();
      }
    }
  }
}
Пример #26
0
void HelloWorld::onMouseDown(Event* event)
{
#ifdef MOUSE_DOUBLE_LISTEN_FUDGE
    mouseDownFudge = !mouseDownFudge;
    if(!mouseDownFudge)
        return;
#endif
    EventMouse* e = (EventMouse*)event;
    isMouseDown[e->getMouseButton()] = true;
    std::stringstream ss;
    ss << "Mouse Down ";
    ss << e->getMouseButton();

    if(e->getMouseButton() == 1)
    {
        if(!getChildByName("animtest"))
        {
            auto s = new O3Sprite("", true);
            addSprite(s);
            s->addAnimation("idle", "animtest", 9, 12);
            s->setAnimation("idle");
            s->playAnimation();
            s->setName("animtest");
        }
        else
        {
            removeChildByName("animtest");
        }
    }
}
Пример #27
0
bool UfoObject::init() {
  //////////////////////////////
  // 1. super init first
  if (!GameObject::init())
  {
    return false;
  }
  
  
  this->schedule(schedule_selector(UfoObject::AIUpdate),1.2);
  addGravityToObject(false);
  setElastic(1.f);
  // SETUP ANIMATIONS
  objectSprite = cocos2d::Sprite::create();
  SpriteFrameCache::getInstance()->addSpriteFramesWithFile("patrol_ufo.plist");
  addAnimation("patrol_ufo ", "ufo_idle", 1, 2, 0.2f);
  setAnimation("ufo_idle");
  objectSprite->setPosition(32, 32);// Aling sprite in Hitbox
  objectSprite->setScale(2);
  addChild(objectSprite);
  
  // Start Speed
  const float xVel = -50;
  setVelocityX(xVel);
  
  plingSFX = SoundFx::create();
  plingSFX->loadEffect("small_explosion.aif", 0, 1, false);
  addChild(plingSFX);
  
  return true;
}
Пример #28
0
EnemyForwardAttack::EnemyForwardAttack(float x,
                                       float y) :
    Ship("enemy_01.png", 3, 1, x, y, 180.0f)
{
    addAnimation("idle", 1, 1, 1.0f);
    playAnimation("idle");
    setVelocity(sf::Vector2f(-200.0f, 0.0f));
}
void SwitchLayout::initKeyboard()
{
    initListWidget();

    fillListWidget();

    addAnimation();
}
Пример #30
0
	OffScreenExplode::OffScreenExplode(int playerNo) : GameElement(0,0)
	{
		this->playerNo = playerNo;
		active = false;
		addAnimation(new Animation("normal",1,"Images/Game/Misc/offscreen_explode.png"));
		changeAnimation("normal", FORWARD);
		setScale(1.1f);
	}