What I want to say is that the role jumps from one step to another. The two steps are different. The result is that the role is parked on another step rather than falling down!
Void MapLayer: mapCreate () {this-> _ allMap = CCTMXTiledMap: create ("map/rosemap. tmx "); this-> _ allMap-> setScale (0.5); this-> addChild (this-> _ allMap ); this-> _ allMap-> layerNamed ("fangluoxia")-> setVisible (true ); // prevent falling invisible CCTMXObjectGroup * objGroup = this-> _ allMap-> objectGroupNamed ("pengzhuang"); 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 for obtaining the key value float x = playerPointDic-> valueForKey ("x ") -> floatValue (); this-> _ y = playerPointDic-> valueForKey ("y")-> floatValue () ;}} void MapLayer: jlmInRoad (float dt) {if (PmdInAllLayer *) this-> getParent ()-> _ jlmLayer-> _ isJlmCreate) {CCSize mapTiledNum = this-> _ allMap-> getMapSize (); CCSize tiledSize = this-> _ allMap-> getTileSi Ze (); CCPoint point1 = (PmdInAllLayer *) this-> getParent ()-> _ jlmLayer-> _ jlmSprite-> getPosition (); int x = point1.x * 2/tiledSize. width; int y = point1.y * 2/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 = _ allMap-> layerNamed ("fangluoxia")-> tileGIDAt (ccp (x, y); if (tiledGid! = 0) {CCDictionary * propertiesDict = _ allMap-> propertiesForGID (tiledGid ); /* obtain the zhezhao attribute value of the grid */const CCString * prop = propertiesDict-> valueForKey ("flx");/* determine whether the zhezhao attribute is true. If yes, do not move players */if (prop-> m_sString.compare ("true") = 0) {// (PmdInAllLayer *) this-> getParent ()) -> _ jlmLayer-> _ jlmSprite-> setPosition (ccp (PmdInAllLayer *) this-> getParent ()-> _ jlmLayer-> _ jlmSprite-> getPosition (). x, 80); // (PmdInAllLayer *) this-> getParent ()-> _ jlmLayer-> _ jlmSprite-> _ jumpdownhweigh = 90; // (PmdInAllLayer *) this-> getParent ()-> _ jlmLayer-> _ jlmSprite-> setPosition (ccp (PmdInAllLayer *) this-> getParent ()) -> _ jlmLayer-> _ jlmSprite-> getPosition (). x + 0.1 * dt, 100); (PmdInAllLayer *) this-> getParent ()) -> _ jlmLayer-> _ jlmSprite-> setPosition (ccp (PmdInAllLayer *) this-> getParent ()-> _ jlmLayer-> _ jlmSprite-> getPosition (). x + 0.1 * dt, 0.5 * this-> _ y) ;}} else {(PmdInAllLayer *) this-> getParent ()) -> _ jlmLayer-> _ jlmSprite-> setPosition (ccp (PmdInAllLayer *) this-> getParent ()-> _ jlmLayer-> _ jlmSprite-> getPosition (). x, (PmdInAllLayer *) this-> getParent ()-> _ jlmLayer-> _ jlmSprite-> getPosition (). y-100.0 * dt ));}}}
This is basically the case!