Exemplo n.º 1
0
void LayerGame::update(float fDelta)
{
    
    CCArray* blockNodes = m_pSpriteBatchNode->getChildren();
    CCObject* child;
    CCARRAY_FOREACH(blockNodes,child )
    {
        SpriteBlock* spBlock = dynamic_cast<SpriteBlock*>(child);
        if (spBlock && isCollison(spBlock, _spRuner)) {
            _spRuner->dead();

        }
    }
Exemplo n.º 2
0
void Stage1::update(float delta)
{
	Vec2 mapPos = map->getPosition();
	Vec2 landScapePos = map1->getPosition();
	Vec2 treesPos = trees->getPosition();
	if ((oriX - warrior->getPosition().x) <= -200)
	{
		mapPos.x += ((oriX + 200) - warrior->getPosition().x);
		landScapePos.x += ((oriX + 200) - warrior->getPosition().x) / 100;
		treesPos.x += ((oriX + 200) - warrior->getPosition().x) / 10;
		oriX = warrior->getPosition().x - 200;
	}
	else if ((oriX - warrior->getPosition().x) >= 200)
	{
		mapPos.x += ((oriX -200 ) - warrior->getPosition().x);
		landScapePos.x += ((oriX - 200) - warrior->getPosition().x) / 100;
		treesPos.x += ((oriX - 200) - warrior->getPosition().x) / 10;
		oriX = warrior->getPosition().x + 200;
	}
	if ((oriY - warrior->getPosition().y) <= -100)
	{
		mapPos.y += ((oriY + 100) - warrior->getPosition().y);
		landScapePos.y += ((oriY + 100) - warrior->getPosition().y) / 100;
		treesPos.y += ((oriY + 100) - warrior->getPosition().y) / 10;
		oriY = warrior->getPosition().y - 100;
	}
	else if ((oriY - warrior->getPosition().y) >= 100)
	{
		mapPos.y += ((oriY - 100) - warrior->getPosition().y);
		landScapePos.y += ((oriY - 100) - warrior->getPosition().y) / 100;
		treesPos.y += ((oriY - 100) - warrior->getPosition().y) / 10;
		oriY = warrior->getPosition().y + 100;
	}
	map->setPosition(mapPos);
	map1->setPosition(landScapePos);
	trees->setPosition(treesPos);

	


	//static float y = 0;
	//y -= 0.1f;
	//map->setPositionY(y);
	return;
	static int time = 0;
	if (time++ % main->getshootSpeed() == 0)
	{
		main->onFire(bulletLayer);
	}

	Vector<Sprite*> removeBullet;
	Vector<Sprite*> removeEm;

	for (int i = 0; i < bulletLayer->getChildren().size(); i++)
	{
		//break;
		Sprite* bullet = (Sprite*)bulletLayer->getChildren().at(i);

		for (int j = 0; j < map->getChildren().size(); j++){
			Sprite* sp = (Sprite*)map->getChildren().at(j);
			if (sp->getName() == "map")
				continue;
			else
			{
				if (isCollison(sp, bullet))
				{
					removeBullet.pushBack(bullet);
					removeEm.pushBack(sp);
				}
				else if ((sp->getPosition().y > 1000 || sp->getPosition().x > 1000
					|| sp->getPosition().y < -10 || sp->getPosition().x < -10)
					)
				{
					removeEm.pushBack(sp);
				}
				else if ((bullet->getPosition().y > 1000 || bullet->getPosition().x > 1000
					|| bullet->getPosition().y < -10 || bullet->getPosition().x < -10)
					)
				{
					removeBullet.pushBack(bullet);
				}
			}
		}
	}
	REMOVE_DELETE_SPRITE(bulletLayer, removeBullet);
	REMOVE_DELETE_SPRITE(map, removeEm);
}