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


C++ MyObject::setProperties方法代码示例

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


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

示例1: if

	//CCDictionary* dict = NULL;
	//CCObject *pObject = NULL;
	CCARRAY_FOREACH(pChildrenArray,pObject)
	{
		dict = (CCDictionary *)pObject;
		if(!dict)
			break;
		const char* key = "name";
		CCString* name = (CCString*)dict->objectForKey(key);
		if(name->isEqual(CCString::create("fire")))
		{
			key = "x";
			int x = ((CCString*)dict->objectForKey(key))->intValue();
			key = "y";
			int y = ((CCString*)dict->objectForKey(key))->intValue();
			addFire(ccp(x,y));
		}else if(name->isEqual(CCString::create("monster")))
		{
			key = "x";
			int x = ((CCString*)dict->objectForKey(key))->intValue();
			key = "y";
			int y = ((CCString*)dict->objectForKey(key))->intValue();
			key = "plistname";
			CCString* temp = ((CCString*)dict->objectForKey(key));
			string* plistname = new string(temp->getCString());
			plistname->append(".plist");
			string* spritename = new string(temp->getCString());
			spritename->append("_%d.png");

			MySprite* sprite =	MySprite::getInstance(ccp(x,y),plistname->c_str(),spritename->c_str(),m_pMyworld);		

			key = "enemy";
		    sprite->setType(((CCString*)dict->objectForKey(key))->isEqual(CCString::create("true")));//设置 敌人

			sprite->setTag(m_iMosterSpriteTag);
	

			if (((CCString*)dict->objectForKey(key))->isEqual(CCString::create("true"))){//如果是敌人
				m_iResuduoMonsterNum++;
				sprite->setCallbackFunc(this,callfunc_selector(GameSceneLayer::gameVictory));
			}else{
				sprite->setCallbackFunc(this,callfunc_selector(GameSceneLayer::gameFaild));
			}

			this->addChild(sprite);
			delete plistname;
			delete spritename;
		}else if(name->isEqual(CCString::create("wood")))
		{
			key = "x";
			int x = ((CCString*)dict->objectForKey(key))->intValue();
			key = "y";
			int y = ((CCString*)dict->objectForKey(key))->intValue();
			key = "sprite_name";
			CCString* sprite_name= (CCString*)dict->objectForKey(key);
			MyObject* sprite =	MyObject::getInstance(ccp(x,y),sprite_name->getCString(),m_pMyworld,MyObject::WOOD);		
			this->addChild(sprite);
		}else if(name->isEqual(CCString::create("iron_v")))
		{
			key = "x";
			int x = ((CCString*)dict->objectForKey(key))->intValue();
			key = "y";
			int y = ((CCString*)dict->objectForKey(key))->intValue();

			key = "bottom";
			int bottom = ((CCString*)dict->objectForKey(key))->intValue();
			key = "speed";
			int speed = ((CCString*)dict->objectForKey(key))->intValue();
			key = "top";
			int top = ((CCString*)dict->objectForKey(key))->intValue();

			MyObject* sprite =	MyObject::getInstance(ccp(x,y),"iron_v.png",m_pMyworld,MyObject::IRON_V);	
			sprite->setProperties(ccp(0,speed),ccp(top,bottom),ccp(0,0));
			this->addChild(sprite);
		}else if(name->isEqual(CCString::create("iron_h")))
		{
			key = "x";
			int x = ((CCString*)dict->objectForKey(key))->intValue();
			key = "y";
			int y = ((CCString*)dict->objectForKey(key))->intValue();

			key = "left";
			int left = ((CCString*)dict->objectForKey(key))->intValue();
			key = "speed";
			int speed = ((CCString*)dict->objectForKey(key))->intValue();
			key = "right";
			int right = ((CCString*)dict->objectForKey(key))->intValue();

			MyObject* sprite =	MyObject::getInstance(ccp(x,y),"iron_h.png",m_pMyworld,MyObject::IRON_H);	
			sprite->setProperties(ccp(speed,0),ccp(0,0),ccp(left,right));
			this->addChild(sprite);
		}else if(name->isEqual(CCString::create("triangle")))
		{
			key = "x";
			int x = ((CCString*)dict->objectForKey(key))->intValue();
			key = "y";
			int y = ((CCString*)dict->objectForKey(key))->intValue();
			MyObject* sprite =	MyObject::getInstance(ccp(x,y),"triangle.png",m_pMyworld,MyObject::TRIANGLE);		
			this->addChild(sprite);
		}else if(name->isEqual(CCString::create("circle")))
//.........这里部分代码省略.........
开发者ID:joyfish,项目名称:bombZombie,代码行数:101,代码来源:GameSceneLayer.cpp


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