bool HeroSprite::isLeftWall(Point nextPos) { auto mapLayer=_map->getLayer("Map"); CCASSERT(mapLayer!=nullptr,"map is error ---HeroSprite::isGround"); auto heroSize=getSpriteFrame()->getRect().size; auto leftPos=Point(nextPos.x-heroSize.width/2,nextPos.y); int x=posToCoordinate(leftPos).x; int y=posToCoordinate(leftPos).y; auto gid=mapLayer->getTileGIDAt(Point(x,y)); if (gid==1||gid==2||gid==3|| gid==4||gid==5||gid==6|| gid==21||gid==22||gid==23|| gid==24|| gid==25||gid==26||gid==27) { return true; } auto leftFootPos=Point(nextPos.x-heroSize.width/2,nextPos.y-heroSize.height/2); int footx=posToCoordinate(leftFootPos).x; int footy=posToCoordinate(leftFootPos).y; auto footgid=mapLayer->getTileGIDAt(Point(footx,footy)); if (footgid==1||footgid==2||footgid==3|| footgid==4||footgid==5||footgid==6|| footgid==21||footgid==22||footgid==23|| footgid==24|| footgid==25||footgid==26||footgid==27) { return true; } return false; }
时间: 2024-10-26 20:45:16