Пример #1
0
// on "init" you need to initialize your instance
bool MainScene::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
 	//load frames into cache
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("image/role.plist","image/role.pvr.ccz");
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("image/ui.plist","image/ui.pvr.ccz");

	addRoles();
	addUI();
	addListener();
	addObserver();
    return true;
}
Пример #2
0
	void addRow(QmlModelRow* row)
	{
		if (row->parent() == nullptr)
		{
			rows_.append(row);
		}

		auto& self = static_cast<QmlTreeModel&>(self_);
		self.endInsertRows();

		columnConnections_.push_back(QtConnectionHolder());
		addRowConnections(row, columnConnections_.back());

		addRoles(row);
		flushPendingChanges();
	}
Пример #3
0
// on "init" you need to initialize your instance
bool Brave::init()
{
	//////////////////////////////
	// 1. super init first
	if (!Layer::init())
	{
		return false;
	}

	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("ui.plist", "ui.pvr.ccz");
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("role.plist", "role.pvr.ccz");

	Size visibleSize = Director::getInstance()->getVisibleSize();
	Vec2 origin = Director::getInstance()->getVisibleOrigin();

// 	Sprite * background = Sprite::create("background.png");
// 	background->setPosition(origin + visibleSize / 2);
// 	this->addChild(background);
	

// 	player = Player::create(Player::PlayerType::PLAYER);
// 	player->setPosition(origin.x + player->getContentSize().width / 2, origin.y + visibleSize.height / 2);
// 	this->addChild(player);
// 
// 	enemy1 = Player::create(Player::PlayerType::ENEMY1);
// 	enemy1->setPosition(origin.x + visibleSize.width - player->getContentSize().width / 2, origin.y + visibleSize.height / 2);
// 	this->addChild(enemy1);
// 
// 	enemy2 = Player::create(Player::PlayerType::ENEMY2);
// 	enemy2->setPosition(VisibleRect::right().x - player->getContentSize().width / 2, VisibleRect::top().y / 2);
// 	this->addChild(enemy2);

	//player->playAnimationForever(1);
	//enemy1->playAnimationForever(1);
	//enemy2->playAnimationForever(1);

// 	_listener_touch = EventListenerTouchOneByOne::create();
// 	_listener_touch->onTouchBegan = CC_CALLBACK_2(Brave::onTouchBegan, this);
// 	_eventDispatcher->addEventListenerWithSceneGraphPriority(_listener_touch, this);
// 
// 	//auto fsm = fsm::FSM::create("idle", [](){cocos2d::log("enter idle"); });
// 
// 	_listener_contact = EventListenerPhysicsContact::create();
// 	_listener_contact->onContactBegin = CC_CALLBACK_1(Brave::onContactBegin, this);
// 	_listener_contact->onContactSeperate = CC_CALLBACK_1(Brave::onContactSeperate, this);
// 	_eventDispatcher->addEventListenerWithFixedPriority(_listener_contact, 10);
// 
// 	NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(Brave::clickEnemy), "clickEnemy", nullptr);


// 	process = Progress::create("player-progress-bg.png", "player-progress-fill.png");
// 	process->setPosition(VisibleRect::left().x + process->getContentSize().width /2, VisibleRect::top().y - process->getContentSize().height / 2);
// 	this->addChild(process);
// 
// 	auto pauseItem = CustomTool::createMenuItemImage("pause1.png", "pause2.png",CC_CALLBACK_1(Brave::onTouchPause,this));
// 	pauseItem->setPosition(VisibleRect::right().x - pauseItem->getContentSize().width / 2, VisibleRect::top().y - pauseItem->getContentSize().height / 2);
// 
// 	auto debugItem = MenuItemImage::create("CloseNormal.png", "CloseSelected.png", CC_CALLBACK_1(Brave::toggleDebug, this));
// 	debugItem->setScale(2.0);
// 	debugItem->setPosition(Vec2(VisibleRect::right().x - debugItem->getContentSize().width - pauseItem->getContentSize().width,
// 		VisibleRect::top().y - debugItem->getContentSize().height));
// 
// 	//_menu = Menu::create(pauseItem, NULL);
// 	_menu = Menu::create(pauseItem, debugItem, NULL);
// 
// 	_menu->setPosition(0, 0);
// 	this->addChild(_menu);
	initLevel();
	addRoles();
	addUI();
	addListener();
	addObserver();

	//this->schedule(schedule_selector(Brave::enemyMove), 1);
	this->schedule(schedule_selector(Brave::enemyMove, 3));
	this->scheduleUpdate();
    return true;
}