如何制作一个类似于 Cortex 接口的接口? (圆,cocos2d,iphone)
如何用 cocos2d for iphone 制作这样的界面? 皮质接口
我已经创建了 CCSprite 的子类并重写 draw
方法,如下所示:
-(void)draw {
ccDrawCircle(CGPointMake(480/2, 320/2), 70, 0, 50000, NO);
ccDrawCircle(CGPointMake(480/2, 320/2), 25, 0, 50000, NO);
ccDrawLine(CGPointMake(480/2, 320/2+25), CGPointMake(480/2, 320/2+70));
ccDrawLine(CGPointMake(480/2+25, 320/2), CGPointMake(480/2+70, 320/2));
ccDrawLine(CGPointMake(480/2, 320/2-25), CGPointMake(480/2, 320/2-70));
ccDrawLine(CGPointMake(480/2-25, 320/2), CGPointMake(480/2-70, 320/2));
}
问题是我没有对圆圈的任何控制(无法设置它的位置)......而且我不知道如何将文本/图像放入这些“单元格”中。另一个问题是触摸检测..也许只是 cgrects?但是如果我有超过 4 个单元格并且其中一个单元格“旋转”怎么办?
有什么想法吗?
How can I make such an interface with cocos2d for iphone? Cortex interface
I already made a subclass of CCSprite and override the draw
method like this:
-(void)draw {
ccDrawCircle(CGPointMake(480/2, 320/2), 70, 0, 50000, NO);
ccDrawCircle(CGPointMake(480/2, 320/2), 25, 0, 50000, NO);
ccDrawLine(CGPointMake(480/2, 320/2+25), CGPointMake(480/2, 320/2+70));
ccDrawLine(CGPointMake(480/2+25, 320/2), CGPointMake(480/2+70, 320/2));
ccDrawLine(CGPointMake(480/2, 320/2-25), CGPointMake(480/2, 320/2-70));
ccDrawLine(CGPointMake(480/2-25, 320/2), CGPointMake(480/2-70, 320/2));
}
The problem is that I don't have any control over the circle (can't set the position of it)...and i don't know how to place text/images into these "cells". Another problem is the touch detection..mayby just cgrects? but what if i have more than 4 cells and one cell is "rotated"?
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你在这里有两个选择,但我不建议子类化 CCSprite,事实上很少会建议这样做,几乎没有必要。
在我看来,您可以执行以下任一操作来获得您的图像。
1. 使用OpenGL绘制图像。
2. 使用CCSprite 绘制图像。 (更清洁)
一旦你绘制了它,只需按下屏幕即可创建它。
一旦您按下屏幕(或任何规定的物体),我就会采用一个简单的三角函数解决方案。
这是我将使用的算法:
(伪代码):
I think you have two options here, but I don't recommend subclassing CCSprite, infact very rarely would recommend doing so, theres almost no need to.
In my opinion, you could do either of these to get your image.
1. Use OpenGL to draw your image.
2. Use CCSprite to draw your image. (Cleaner)
Once you have drawn it, its simply a matter of creating it when you press down on the screen.
Once you press down on the screen (or any prescribed object) I would then employ a simple trigonometric solution.
This is the algorithm I would use:
(PSUDOCODE):
我认为创建 CCSprite 的子类在这里不是正确的选择。您可能需要一个 NSObject 来为您创建 CCSprites。
另外,
CCSprite.position = CGPointMake( X, Y )
应该允许您设置精灵的位置。不要忘记将其添加到图层中,就像任何其他 CCNode 对象一样。I don't think making a subclass of CCSprite is the right choice here. You will probably want a NSObject that creates the CCSprites for you.
Also
CCSprite.position = CGPointMake( X, Y )
should allow you to set the position of the sprite. Don't forget to add it to a layer just like any other CCNode object.