********** **************************************** * ********************************/Void JlmLayer:: ciCreate (float dt) {CCTMXObjectGroup * objGroup = (PmdInAllLayer *) this-> getParent ()-> _ mapLayer-> _ allMap-> objectGroupNamed ("ci "); CCArray * objArray = objGroup-> getObjects (); if (objArray & objArray-> count ()> 0) {CCObject * pObj = NULL; CCARRAY_FOREACH (objArray, pObj ){ CCDictionary * playerPointDic = (CCDictionary *) pObj; // converts an object to a dictionary to obtain the key value float x = playerPointDic-> valueForKey ("x")-> floatValue (); float y = playerPointDic-> valueForKey ("y")-> floatValue (); this-> _ ci = CCSprite: createWithSpriteFrameName ("ci.png "); this-> _ jlmBatchNode-> addChild (this-> _ ci); this-> _ ciArray-> addObject (this-> _ ci ); this-> _ ci-> setPosition (ccp (1.8f * x, 1.8f * y); this-> _ ci-> setScale (0.6f);} thi S-> _ isJlmCreate = true; if (this-> _ isJlmCreate) {unschedule (schedule_selector (JlmLayer: ciCreate);} void JlmLayer: ciZhuAi (float dt) {if (this-> _ isJlmCreate) {CCSize mapTiledNum = (PmdInAllLayer *) this-> getParent ()-> _ mapLayer-> _ allMap-> getMapSize (); CCSize tiledSize = (PmdInAllLayer *) this-> getParent ()-> _ mapLayer-> _ allMap-> getTileSize (); CCPoint point1 = (PmdInAllLayer *) this-> getParent ()-> _ jlm Layer-> _ jlmSprite-> getPosition (); int x = 0.5 * point1.x/tiledSize. width; int y= 0.5 * point1.y/tiledSize. height;/* the default Y coordinate of the Cocos2d-x is from bottom to top, so do a subtraction operation */y = mapTiledNum. height-y; int tiledGid = (PmdInAllLayer *) this-> getParent ()-> _ mapLayer-> _ allMap-> layerNamed ("fangluoxia ") -> tileGIDAt (ccp (x, y); if (tiledGid! = 0) {CCDictionary * propertiesDict = (PmdInAllLayer *) this-> getParent ()-> _ mapLayer-> _ allMap-> propertiesForGID (tiledGid ); /* obtain the zhezhao attribute value of the grid */const CCString * prop = propertiesDict-> valueForKey ("zhangai");/* determine whether the zhezhao attribute is true. If yes, do not move players */if (prop-> m_sString.compare ("true") = 0) {this-> _ jlmSprite-> _ spedV = CCPointZero ;}}} void JlmLayer:: ciRemove (CCNode * spend) {CCSprite * sprite = (CCSprite *) spend; this-> _ ciArray-> removeObject (sprite, true ); this-> _ jlmBatchNode-> removeChild (sprite, true );} /*************************************** **************************************** **********************************/