Cocos2D-x - 使用CCFollow时的问题

时间:2013-10-21 20:00:24

标签: screen box2d cocos2d-x

我在Cocos2D-X中遇到CCFollow问题。我想跟随我的Sprite,它被称为Box2D-Body。

当我打电话

this->runAction(CCFollow::create(playerSprite));

在我的GameLayer的init方法中,我平常屏幕的左下角以我的设备为中心,虽然是模拟器。

愿任何人帮我解决这个问题吗? :/

最诚挚的问候,

stotheg

2 个答案:

答案 0 :(得分:2)

ССFollow通常不足以满足您自己的目的。摆脱这种情况的一种方法是创建自定义的ССFollow操作或在游戏循环中添加所需的逻辑。

请阅读这篇文章,您的问题有很多有用的信息:
The Four Ways of Implementing a Scrolling View with Cocos2D Explained

答案 1 :(得分:0)

可能是在将图层的VisibleBoundsWorldspace设置为视图宽度和高度之前实例化CCFollow(如果VisibleBoundsWorldspace矩形的宽度和高度为零,则检查调试器。)

protected void Button1_Click(object sender, EventArgs e)
{
Response.Clear();

Response.AddHeader("content-disposition", "attachment;
filename=FileName.xls");


Response.ContentType = "application/vnd.xls";

System.IO.StringWriter stringWrite = new System.IO.StringWriter();

System.Web.UI.HtmlTextWriter htmlWrite =
new HtmlTextWriter(stringWrite);

GridView1.RenderControl(htmlWrite);

Response.Write(stringWrite.ToString());

Response.End();

}

不应该在Layer构造函数中,像AddedToScene这样的地方会更好。