当前位置: 首页>>代码示例>>C++>>正文


C++ DataModel类代码示例

本文整理汇总了C++中DataModel的典型用法代码示例。如果您正苦于以下问题:C++ DataModel类的具体用法?C++ DataModel怎么用?C++ DataModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DataModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

Wave *HelloWorld::getCurrentWave(){
	
	DataModel *m = DataModel::getModel();
	Wave * wave = (Wave *) m->getWaves()->objectAtIndex(_currentLevel);
	
	return wave;
}
开发者ID:pototao,项目名称:DefenseTest,代码行数:7,代码来源:HelloWorldScene.cpp

示例2: tileCoordForPosition

bool HelloWorld::canBuildOnTilePosition(CCPoint pos)
{
//    pos=ccpAdd(pos, ccp(0, 50));
	CCPoint towerLoc = tileCoordForPosition(pos);
	
	int tileGid =_background->tileGIDAt(towerLoc);
	CCDictionary *props = _tileMap->propertiesForGID(tileGid);
	const CCString *type = props->valueForKey("buildable");
	CCString* str=CCString::create("1");
   
    DataModel *m = DataModel::getModel();
     bool occupied = false;
    for (int i=0;i< m->getTowers()->count();i++) {
        Towers *tower=(Towers*)m->getTowers()->objectAtIndex(i);
        CCRect towerRect = CCRectMake(tower->getPosition().x - (tower->getContentSize().width/2),
                                      tower->getPosition().y - (tower->getContentSize().height/2),
                                      tower->getContentSize().width, tower->getContentSize().height);
        if (towerRect.containsPoint(pos)) {
            occupied = true;
        }
    }
    
	if(str->isEqual(type)&&!occupied) {
		return true;
	}
	
	return false;
}
开发者ID:pototao,项目名称:DefenseTest,代码行数:28,代码来源:HelloWorldScene.cpp

示例3: updateItem

void CustomItemProvider::updateItem(Picker * pickerList, int columnIndex, int rowIndex,
        VisualNode * pickerItem)
{
    DataModel *model = pickerList->dataModel();
    QVariantList indexPath;
    indexPath << columnIndex << rowIndex;

    // When
    if (model->data(indexPath).canConvert(QVariant::Map)) {
        QVariantMap dataMap = model->data(indexPath).toMap();

        // Find the item label for which the text will be updated to correspond to the model value.
        Label * itemLabel = pickerItem->findChild<Label *>("itemLabel");
        Label * sliceLabel = pickerItem->findChild<Label *>("sliceLabel");

        switch (columnIndex) {
            case PIZZA_ITEM:
                itemLabel->setText(dataMap["text"].toString());
                break;
            case STYLE_ITEM:
                itemLabel->setText(dataMap["text"].toString());
                break;
            case SIZE_ITEM:
                itemLabel->setText(dataMap["text"].toString());
                sliceLabel->setText("x" + dataMap["slices"].toString());
                break;
        }
    }
}
开发者ID:13natty,项目名称:Cascades-Samples,代码行数:29,代码来源:customitemprovider.cpp

示例4: finishFiring

void Towers::finishFiring() {
	if (!_target) {
		return;
	}
	DataModel *m = DataModel::getModel();

	setNextBullet(Bullet::create(BULLET_NAME[bulletTag].c_str(),bulletTag,Info::getInfo()->bulletInfo->value[bulletTag]));
	getNextBullet()->setPosition(getPosition());

	this->getParent()->addChild(getNextBullet(),1);
	m->getProjectiles()->addObject(getNextBullet());

	float delta = 1.0;
	CCPoint shootVector = ccpSub(_target->getPosition(),getPosition());
	CCPoint normalizedShootVector = ccpNormalize(shootVector);
	CCPoint overshotVector = ccpMult(normalizedShootVector, 320);
	CCPoint offscreenPoint = ccpAdd(getPosition(), overshotVector);

	getNextBullet()->runAction(CCSequence::create(CCMoveTo::create(delta,offscreenPoint),
		CCCallFuncN::create(this,callfuncN_selector( Towers::creepMoveFinished)),NULL));

	getNextBullet()->setTag(bulletTag);

	setNextBullet(NULL);

}
开发者ID:pototao,项目名称:DefenseTest,代码行数:26,代码来源:Towers.cpp

示例5: creepMoveFinished

void Towers::creepMoveFinished(CCNode* sender) {

	DataModel * m = DataModel::getModel();

	CCSprite *sprite =(CCSprite*)sender;
	this->getParent()->removeChild(sprite,true);
	m->getProjectiles()->removeObject(sprite);

}
开发者ID:pototao,项目名称:DefenseTest,代码行数:9,代码来源:Towers.cpp

示例6: restartEvent

void StartScene::restartEvent(Widget* target, TouchEventType type)
{
    if(type==TouchEventType::TOUCH_EVENT_ENDED) {
        DataModel *m = DataModel::getModel();
        m->clear();
        auto replaceScene = TransitionFadeBL::create(2, createScene());
        Director::getInstance()->replaceScene(replaceScene);
    }
}
开发者ID:hustjf,项目名称:ProtectTank,代码行数:9,代码来源:StartScene.cpp

示例7: mainMenuEvent

void StartScene::mainMenuEvent(Widget* target, TouchEventType type)
{
    if(type==TouchEventType::TOUCH_EVENT_ENDED) {
        DataModel *m = DataModel::getModel();
        m->clear();
        auto replaceScene = TransitionFlipAngular::create(2, HelloWorld::createScene());

        Director::getInstance()->replaceScene(replaceScene);
    }
}
开发者ID:hustjf,项目名称:ProtectTank,代码行数:10,代码来源:StartScene.cpp

示例8: onListSelectionChanged

void MainMenu::onListSelectionChanged(const QVariantList indexPath) {

	if (sender()) {
		ListView* menuList = dynamic_cast<ListView*>(sender());
		DataModel* menuModel = menuList->dataModel();

		QVariantMap map = menuModel->data(indexPath).toMap();
		if (map["itemName"].canConvert(QVariant::String)) {
			QString item = map["itemName"].toString();

			qDebug() << "XXXX selected item name=" << item;

			if (item.compare("item_read") == 0) {
				qDebug() << "XXXX Read Tag was selected!";
				StateManager* state_mgr = StateManager::getInstance();
				state_mgr->setEventLogShowing(true);
				_eventLog->setMessage("Bring a tag close");
				emit read_selected();

			} else if (item.compare("item_uri") == 0) {
				qDebug() << "XXXX Write URI was selected!";
				emit write_uri();

			} else if (item.compare("item_sp") == 0) {
				qDebug() << "XXXX Write SP was selected!";
				emit write_sp();

			} else if (item.compare("item_text") == 0) {
				qDebug() << "XXXX Write Text was selected!";
				emit write_text();

			} else if (item.compare("item_custom") == 0) {
				qDebug() << "XXXX Write Custom was selected!";
				emit write_custom();

			} else if (item.compare("item_about") == 0) {
				qDebug() << "XXXX About was selected!";
				emit about_selected();

			} else if (item.compare("item_snep_vcard") == 0) {
				qDebug() << "XXXX Send vCard (SNEP) was selected!";
				emit send_vcard_selected();

			} else if (item.compare("item_emulate_tag") == 0) {
				qDebug() << "XXXX Emulate Tag was selected!";
				emit emulate_tag_selected();
			} else if (item.compare("item_iso7816") == 0) {
				qDebug() << "XXXX ISO7816 APDU was selected!";
				StateManager* state_mgr = StateManager::getInstance();
				state_mgr->setEventLogShowing(true);
				emit iso7816_selected();
			}
		}
	}
}
开发者ID:theclabs,项目名称:BB10-MC-VISA-NFC,代码行数:55,代码来源:MainMenu.cpp

示例9: addWaves

void HelloWorld::addWaves() {
	DataModel *m = DataModel::getModel();
	
    for (int i=0; i<5; i++) {
        Wave * wave =new Wave();
		Creeps* creep=Creeps::create(ENERMY_NAME[i%2].c_str(),i%2,Info::getInfo()->creepInfo->value[i%2]);
        wave->initWithCreep(creep, 1.0,5+i*10,0+i*5);
        m->getWaves()->addObject(wave);
        wave = NULL;
    }

}
开发者ID:pototao,项目名称:DefenseTest,代码行数:12,代码来源:HelloWorldScene.cpp

示例10: Kick

	/**
	 * Kicks the player from the server.
	 * @author John M. Harris, Jr.
	 */
	void Player::Kick(){
		OpenBlox::OBGame* game = OpenBlox::OBGame::getInstance();
		if(!game){ return; }
		if(game->isServer()){
			DataModel* dm = game->getDataModel();
			if(dm){
				Instance* nsi = dm->FindService("NetworkServer");
				if(nsi){
					NetworkPeer* ns = dynamic_cast<NetworkPeer*>(nsi);
					if(ns){
						std::vector<Instance*> nrs = ns->GetChildren();
						for(std::vector<Instance*>::size_type i = 0; i != nrs.size(); i++){
							Instance* kid = nrs[i];
							if(kid){
								if(NetworkReplicator* nr = dynamic_cast<NetworkReplicator*>(kid)){
									if(nr->GetPlayer() == this){
										RakNet::SystemAddress addr = nr->getAddress();
										RakNet::RakPeerInterface* peer = ns->getPeer();
										if(peer){
											peer->CloseConnection(addr, true, 0, HIGH_PRIORITY);
										}
									}
								}
							}
						}
					}
				}
			}
		}else{
			DataModel* dm = game->getDataModel();
			if(dm){
				Instance* plrsi = dm->FindService("Players");
				if(plrsi){
					if(Players* plrs = dynamic_cast<Players*>(plrsi)){
						if(plrs->getLocalPlayer() == this){
							Instance* nci = dm->FindService("NetworkClient");
							if(nci){
								if(NetworkClient* nc = dynamic_cast<NetworkClient*>(nci)){
									nc->Disconnect();
								}
							}
							return;
						}
					}
				}
			}
			WLOG("Attempt to kick a player from client.");
		}
	}
开发者ID:RobloxLabs,项目名称:OpenBlox,代码行数:53,代码来源:Player.cpp

示例11: printStatus

void printStatus(ostream& out, DataModel& data)
{
	SpeakerDictionary::iterator it;
	int nb[3] = { 0, 0, 0};

	for ( it = data.getSpeakerDictionary().begin();
		it != data.getSpeakerDictionary().end(); ++it )
		nb[it->second.getGender()]++;

	out << "\t total duration : " <<  data.getSignalDuration() << " s" << endl;
	out << "\t nb tracks      : " <<  data.getNbTracks() << endl;
	out << "\t nb speakers    : " <<  data.getSpeakerDictionary().size() << endl;
	out << "\t repartition    : " <<  "male: " << nb[1] << "  female: " << nb[2] << "  undef: " << nb[0] << endl;
	out << endl;
}
开发者ID:eroux,项目名称:transcriber-ag,代码行数:15,代码来源:tagstats.cpp

示例12: onSelectionChanged

void StampCollectorApp::onSelectionChanged(const QVariantList indexPath, bool selected)
{
    if (selected) {
        // We use the sender to get the list view for accessing the data model and then the actual data.
        if(sender()) {
            ListView* stampList = dynamic_cast<ListView*>(sender());
            DataModel* stampModel = stampList->dataModel();

            // Update the content view context property so that it corresponds to
            // the selected item and navigate to the page.
            QVariantMap map = stampModel->data(indexPath).toMap();
            mQmlContext->setContextProperty("_contentView", map);
            mNav->push(mContentPage);
        }
    }
}
开发者ID:drkillinger,项目名称:Cascades-Samples,代码行数:16,代码来源:stampcollectorapp.cpp

示例13: main

int main(int argc, char *argv[])
{
	// 加载相机参数
	DataModel* m = DataModel::getInstance();
	if(!m->loadParameters("cameras_info.xml"))
	{
		MessageBox(NULL, TEXT("未缺少xml文件,无法进行自动检测!"), TEXT("错误"), MB_OK);
	}
	m = NULL;
	QTextCodec::setCodecForTr(QTextCodec::codecForName("GB2312"));
	QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GB2312"));
	QTextCodec::setCodecForLocale(QTextCodec::codecForName("GB2312"));
	QApplication a(argc, argv);
	QApplication::setStyle("cleanlooks"); 
	LZ_MainWindow w;
	w.setWindowOpacity(1);  
	//w.setWindowFlags(Qt::FramelessWindowHint); 
	w.show();
	return a.exec();
}
开发者ID:AllenYick,项目名称:LZProject,代码行数:20,代码来源:main.cpp

示例14: addWaypoint

void HelloWorld::addWaypoint() {
	DataModel *m = DataModel::getModel();
	
	CCTMXObjectGroup *objects =_tileMap->objectGroupNamed("Objects");
	WayPoint *wp = NULL;
	
	int spawnPointCounter = 0;
	CCDictionary *spawnPoint;
	while ((spawnPoint =objects ->objectNamed(CCString::createWithFormat("Waypoint%d", spawnPointCounter)->getCString()))) {
		int x = spawnPoint->valueForKey("x")->intValue();
		int y = spawnPoint->valueForKey("y")->intValue();
		
		wp =(WayPoint *)WayPoint::create();
		wp->setPosition(ccp(x, y));
		m->getWaypoints()->addObject(wp);
		spawnPointCounter++;
	}
	
//	NSAssert([m->getWaypoints()->count()] > 0, @"Waypoint objects missing");
	wp = NULL;
}
开发者ID:pototao,项目名称:DefenseTest,代码行数:21,代码来源:HelloWorldScene.cpp

示例15: qDebug

void CustomPickerRecipe::onValueChanged(const QVariant &value)
{
    qDebug() << "value " << value;

    if (value.canConvert(QVariant::List)) {
        QVariantList selectionList = value.toList();
        DataModel *pickerModel = mPicker->dataModel();

        // Get the current pizza type data
        QVariantList pizzaIndexPath;
        pizzaIndexPath << 0 << selectionList.at(0).toInt();
        QVariantMap pizza = pickerModel->data(pizzaIndexPath).toMap();

        // Get the current size item data
        QVariantList sizeIndexPath;
        sizeIndexPath << 1 << selectionList.at(1).toInt();
        QVariantMap size = pickerModel->data(sizeIndexPath).toMap();

        // Get the current extra item data
        QVariantList extraIndexPath;
        extraIndexPath << 2 << selectionList.at(2).toInt();
        QVariantMap extra = pickerModel->data(extraIndexPath).toMap();

        // Total amount to pay for the pizza.
        float price = pizza["price"].toFloat() * size["factor"].toFloat()
                + extra["price"].toFloat();

        // Update the description label with summary of the order.
        mDescription->setText(
                "Order: " + pizza["text"].toString() + ", " + size["text"].toString() + ", "
                        + extra["text"].toString() + ".");

        // Update the bill label with the total amount to pay for the order.
        mBill->setText("Bill:  " + QString::number(price) + "$");

        // and set the picker description to the total price
        mPicker->setDescription(QString::number(price) + " $");
    }
}
开发者ID:13natty,项目名称:Cascades-Samples,代码行数:39,代码来源:custompickerrecipe.cpp


注:本文中的DataModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。