Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

动作(Action) #180

Open
zhumo521 opened this issue Oct 23, 2018 · 1 comment
Open

动作(Action) #180

zhumo521 opened this issue Oct 23, 2018 · 1 comment

Comments

@zhumo521
Copy link

zhumo521 commented Oct 23, 2018

URL : https://github.com/cocos2d/cocos2d-x-docs/blob/master/zh/actions/index.md
我发现这个示例的动作执行和最终作者要表达的意思可能相悖,是我理解错了吗?
mySprite->setPosition(Vec2(200, 256));// 当前精灵的位置
auto moveBy = MoveBy::create(2, Vec2(500, mySprite->getPositionY()));//相对移动
此处是相对于坐标(200, 256)再移动(500, mySprite->getPositionY()),此处mySprite->getPositionY()是256,最终结果是精灵向它的右上角移动。并非图片展示的那样移动过去再移动回来。
我试着将相对移动的纵坐标修改成0。为了适应在窗口中观察,我把其他坐标做了相应的调整,最终达到了在水平方向上来回移动的效果。
示例代码:
` mySprite->setPosition(Vec2(100, 256));
auto moveby = MoveBy::create(2, Vec2(400, 0));//0使得相对精灵纵向位置不变
auto moveto = MoveTo::create(2, Vec2(100, mySprite->getPositionY()));

	DelayTime* delay = DelayTime::create(1);

	Sequence* seq = Sequence::create(moveby, delay, moveto, nullptr);	
	mySprite->runAction(seq);

`

@slackmoehrle
Copy link
Collaborator

你还需要帮忙吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants