今天看啥
热点:

现在我们在地图上的“Meta”上添加“star”瓦块,然后在代码中添加如下如下:

bool Player::SetPlayerPosition(int x,int y)
{

	CCSize spritesize = m_sprite->getContentSize();
	CCPoint dspoint = CCPoint(x+spritesize.width/2,y);
	CCPoint tiledpos =tileCoordForPosition(ccp(dspoint.x,dspoint.y));
	CCLOG("tiled x = %f,y = %f",tiledpos.x,tiledpos.y);
	int tiledchild = meta->tileGIDAt(tiledpos);
	if(tiledchild != 0)
	{
		CCDictionary * propertydict = m_map->propertiesForGID(tiledchild);
		const CCString * prop = propertydict->valueForKey("Collidable");
		if(prop->m_sString.compare("true") == 0)
		{
            x-=1;
			y-=1;
			//return false;
		}
		const CCString * props = propertydict->valueForKey("star");
		if (props->length()>0&& props->m_sString.compare("true")==0)
		{
			CCTMXLayer *barrier = m_map->layerNamed("barrier");
			barrier->removeTileAt(tiledpos);
		}
	}
	Entity::SetPlayerPosition(x,y);
	SetViewPointByPosition();
	return true;
}

这样当我们的主角运动到星星时,星星会消失。



www.bkjia.comtruehttp://www.bkjia.com/qtjc/754558.htmlTechArticle现在我们在地图上的“Meta”上添加“star”瓦块,然后在代码中添加如下如下: bool Player::SetPlayerPosition(int x,int y){CCSize spritesize = m_sprite->g...

相关文章

相关搜索: 精灵

帮客评论

视觉看点