Cocos2d 2.x: understanding ccBezierConfig beheaviour(Cocos2d 2.x:理解 ccBezierConfig 行为)
问题描述
我很久以前就问过一个 然后做从头到尾对称但颠倒"的东西.
关于我做错了什么有什么建议吗?
ccBezierConfig 贝塞尔曲线;self.position = CGPointMake(0.0f, 150.0f);bezier.controlPoint_1 = CGPointMake(-20.0f, 290.0f);bezier.controlPoint_2 = CGPointMake(260, 290.0f);bezier.endPosition =CGPointMake(340.0f,150.0f);id bezierForward = [CCBezierBy actionWithDuration:3 bezier:bezier];ccBezierConfig bezier2;bezier2.controlPoint_1 = CGPointMake(340.0f, 10.0f);bezier2.controlPoint_2 = CGPointMake(80, 10.0f);bezier2.endPosition =CGPointMake(-20.0f,150.0f);id bezierReturn = [CCBezierBy actionWithDuration:3 bezier:bezier2];[self runAction:[CCSequence 动作:bezierForward, bezierReturn, [CCHide 动作],零]];
我使用的是 CCBezierBy,但示例基于 CCBezierTo 公式.因此,如果我使用 CCBezierTo 代替 CCBezierBy,一切都会按预期工作.
I am on this since a while and time ago I asked a question and a user kindly replied to me explaning that there is this plugin tool that I can use to create quick bezier curves prototypes.
I tried and produced this:
I thought it would be perfectly translated in this ccBezierConfig:
ccBezierConfig bezier;
self.position = CGPointMake(-10.0f, 400.0f);
bezier.controlPoint_1 = CGPointMake(160, 190.0f);
bezier.controlPoint_2 = CGPointMake(200, 190.0f);
bezier.endPosition =CGPointMake(340.0f,280.0f);
id bezierForward = [CCBezierBy actionWithDuration:3 bezier:bezier];
[self runAction: [CCSequence actions:
bezierForward, [CCHide action],
nil]];
Unfortunately the path I get is not quiet what I was expecting. The character starts to move from the top left corner of the screen and then just goes up and I don't see the movement I expected.
Any explanation on what am I doing wrong?
Btw.. I am using Cocos2d 2.0 on iOS 6.0, retina display iPod touch 4th generation.
EDIT:
Another example..
I thought that this configuration would do like in this and then do the symmetric thing from the end to the start but "upside down".
Any suggestions on what am I doing wrong?
ccBezierConfig bezier;
self.position = CGPointMake(0.0f, 150.0f);
bezier.controlPoint_1 = CGPointMake(-20.0f, 290.0f);
bezier.controlPoint_2 = CGPointMake(260, 290.0f);
bezier.endPosition =CGPointMake(340.0f,150.0f);
id bezierForward = [CCBezierBy actionWithDuration:3 bezier:bezier];
ccBezierConfig bezier2;
bezier2.controlPoint_1 = CGPointMake(340.0f, 10.0f);
bezier2.controlPoint_2 = CGPointMake(80, 10.0f);
bezier2.endPosition =CGPointMake(-20.0f,150.0f);
id bezierReturn = [CCBezierBy actionWithDuration:3 bezier:bezier2];
[self runAction: [CCSequence actions:
bezierForward, bezierReturn, [CCHide action],
nil]];
I was using CCBezierBy but the examples are based on a CCBezierTo formula. Hence everything works as excpected if I use CCBezierTo instaed of CCBezierBy.
这篇关于Cocos2d 2.x:理解 ccBezierConfig 行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Cocos2d 2.x:理解 ccBezierConfig 行为
基础教程推荐
- Android:对话框关闭而不调用关闭 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01