Ejemplo n.º 1
0
bool GameScene::init(){
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Point origin = Director::getInstance()->getVisibleOrigin();
    
    auto sprite = Sprite::create("bj2.jpg");
    sprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
    this->addChild(sprite, -4);
    
    auto bg1 = Sprite::create("b2.png");
    bg1->setAnchorPoint(Point(0, 0));
    bg1->setPosition(Point(0, 10));
    this->addChild(bg1, -3);
    
    auto bg2 = Sprite::create("b2.png");
    bg2->setAnchorPoint(Point(0, 0));
    bg2->setPosition(Point(bg1->getContentSize().width, 10));
    this->addChild(bg2, -3);
    
    distanceBg.pushBack(bg1);
    distanceBg.pushBack(bg2);
    
    auto bg3 = Sprite::create("b1.png");
    bg3->setAnchorPoint(Point(0, 0));
    bg3->setPosition(Point(0, 0));
    this->addChild(bg3, -2);
    
    auto bg4 = Sprite::create("b1.png");
    bg4->setAnchorPoint(Point(0, 0));
    bg4->setPosition(bg3->getContentSize().width, 0);
    this->addChild(bg4, -2);
    
    nearbyBg.pushBack(bg3);
    nearbyBg.pushBack(bg4);
    
    ParticleSystemQuad *emiter = ParticleSystemQuad::create("dirt.plist");
    emiter->setPosition(visibleSize.width/2, visibleSize.height/2);
    this->addChild(emiter, -3);
    
    map = TMXTiledMap::create("map.tmx");
    map->setAnchorPoint(Point(0, 0));
    map->setPosition(Point(0, 0));
    this->addChild(map, -1);

    addPlayer(map);
    addHeart(map);
    
    playFlyToScene();
    
    Node *ground = Node::create();
    float width = map->getContentSize().width;
    float height = map->getContentSize().height * 3 / 16;

    auto bottomBody = PhysicsBody::createEdgeSegment(Point(0, height), Point(width, height));
    ground->setPhysicsBody(bottomBody);
    this->addChild(ground);
    
    return true;
}
Ejemplo n.º 2
0
void Level::removeRisen(int index)
{
	// 1/3 chance to spawn heart
	if(rand()%3 == 0)
	{
		addHeart(risenManager.risen[index]->getPosition().x,risenManager.risen[index]->getPosition().y );
	}
	risenManager.risen.erase(risenManager.risen.begin() + index);
}