在那里,当用户将手指从一个点拖到另一个点时,我需要绘制一条线.据我所知,我需要在touches Moved方法中从中获取积分.
但我不知道该怎么做.有人可以帮我这个吗?
解决方法 起亚ora.无聊迫使我提供这个主题的答案.层部分(即@interface GetMytouches:cclayer):
-(voID) cctouchesMoved:(NSSet *)inappropriatetouches withEvent:(UIEvent *)event{ UItouch *touchMyMinge = [inappropriatetouches anyObject]; CGPoint currenttouchArea = [touchMyMinge locationInVIEw:[touchMyminge vIEw] ]; CGPoint lasttouchArea = [touchMyMinge prevIoUsLocationInVIEw:[touchMyMinge vIEw]]; // flip belly up. no one likes being entered from behind. currenttouchArea = [[CCDirector sharedDirector] convertToGL:currenttouchArea]; lasttouchArea = [[CCDirector sharedDirector] convertToGL:lasttouchArea]; // throw to console my inappropriate touches NSLog(@"current x=%2f,y=%2f",currenttouchArea.x,currenttouchArea.y); NSLog(@"last x=%2f,lasttouchArea.x,lasttouchArea.y); // add my touches to the naughty touch array naughtytouchArray addobject:NsstringFromCGPoint(currenttouchArea)]; naughtytouchArray addobject:NsstringFromCGPoint(lasttouchArea)];}
节点部分(即@interface DrawMytouch:CCNode):
@implementation DrawMytouch-(ID) init{ if( (self=[super init])) { } return self;}-(voID)draw{ glEnable(GL_liNE_SMOOTH); for(int i = 0; i < [naughtytouchArray count]; i+=2) { start = CGPointFromString([naughtytouchArray objectAtIndex:i]); end = CGPointFromString([naughtytouchArray objectAtIndex:i+1]); ccDrawline(start,end); }}@end
第二部分层(即@interface GetMytouches:cclayer):
-(voID) cctouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ DrawMytouch *line = [DrawMytouch node]; [self addChild: line];}
记住触摸很容易.在触摸时知道你在做什么并不是火箭科学.
最后,如果你不理解我发布的任何内容……请继续烘焙.世界需要更多的巧克力蛋糕生产商.
澄清:
>没有人学习形式切割’粘贴〜这段代码从来没有打算在没有爱抚的情况下工作
>如果你没有看到幽默,那你就是错误的职业
值得注意的是,我喜欢一个好的巧克力蛋糕.世界确实需要更多出色的面包师.这不是侮辱,而是鼓励.
“在广场外看,找到充满了让生活变得有价值的知识的圈子”~AenesIDemus.
总结以上是内存溢出为你收集整理的ios – 在COCOS2D中移动的绘图线全部内容,希望文章能够帮你解决ios – 在COCOS2D中移动的绘图线所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)