2
A
回答
1
我绘制多行,得到切片的效果,并且同时从该可变数组移除点,其中i把点来绘制线
代码: -
-(void)init
{
[self checkAllArray];
[self schedule:@selector(removePoints:) interval:0.0001f];
}
-(void)checkAllArray
{
if (naughtytoucharray==NULL)
naughtytoucharray=[[NSMutableArray alloc] init];
else
{
[naughtytoucharray release];
naughtytoucharray=nil;
naughtytoucharray=[[NSMutableArray alloc] init];
}
}
-(void)draw
{
glEnable(GL_LINE_SMOOTH);
glColor4ub(255, 255, 255, 255); //line color
//glLineWidth(2.5f);
for(int i = 0; i < [naughtytoucharray count]; i+=2)
{
CGPoint start = CGPointFromString([naughtytoucharray objectAtIndex:i]);
CGPoint end = CGPointFromString([naughtytoucharray objectAtIndex:i+1]);
ccDrawLine(start, end); // line 1
ccDrawLine(ccp(start.x-2,start.y-2),ccp(end.x-2,end.y-2));// line 2
ccDrawLine(ccp(start.x-4,start.y-4),ccp(end.x-4,end.y-4));// line 3
ccDrawLine(ccp(start.x-6,start.y-6),ccp(end.x-6,end.y-6));// line 4
ccDrawLine(ccp(start.x-8,start.y-8),ccp(end.x-8,end.y-8));// line 5
}
}
- (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint new_location = [touch locationInView: [touch view]];
new_location = [[CCDirector sharedDirector] convertToGL:new_location];
CGPoint oldTouchLocation = [touch previousLocationInView:touch.view];
oldTouchLocation = [[CCDirector sharedDirector] convertToGL:oldTouchLocation];
[naughtytoucharray addObject:NSStringFromCGPoint(new_location)];
[naughtytoucharray addObject:NSStringFromCGPoint(oldTouchLocation)];
}
-(void)removePoints:(ccTime *)tm
{
if ([naughtytoucharray count]>0)
{
[naughtytoucharray removeObjectAtIndex:0];
}
}
-(void)dealloc
{
//NSLog(@"deallocing lightning\n");
[self removeAllChildrenWithCleanup:YES];
[super dealloc];
}
0
您在屏幕空间得到几个控制点。然后插入它们并构建沿着该曲线的多个多边形。你可以使用片段着色器来绘制边框或纹理(但我认为它会更困难)。
相关问题
- 1. 像水果忍者一样在游戏中工作的问题
- 2. 想buiild水果忍者类型片的效果
- 3. ActionScript:水果忍者滑动
- 4. jquery图片淡入淡出效果灯箱效果/火影忍者效果
- 5. cocos2d水果忍者抛物线数学
- 6. 切换效果不工作
- 7. cocos 2d检测2个精灵中的同时触摸 - 就像在水果忍者游戏
- 8. 如何在box2d flash游戏中做慢动作效果
- 9. 游戏中的跳跃效果
- 10. 在HTML5游戏中的声音效果
- 11. iPhone游戏中的声音效果
- 12. java游戏中的爆炸效果
- 13. 喜欢在游戏中的Uilabel效果
- 14. 实现水的效果(溅)到XNA 4.0游戏
- 15. 水果射手游戏试图结束
- 16. 贪吃蛇游戏设置水果点
- 17. 游戏如何制作火焰和烟雾效果?
- 18. iphone游戏的灯光效果与cocos2d
- 19. 如何将转换效果添加到我的LibGdx游戏中?
- 20. 如何才能达到“Antichamber”游戏中的效果?
- 21. 雪碧工具包:SKNodes加入动画像水果忍者的屏幕
- 22. Android滑动Puzzzle游戏:幻灯片效果
- 23. 如何在游戏中实现碰撞效果?
- 24. 如何在Box2d的侧视图Flash游戏中做慢动作效果
- 25. 我不知道如果我的游戏工作尚未
- 26. 如何正确渲染效果最好的html5帆布游戏
- 27. 绘制线条效果触摸像水果忍者或素食武士和发动机
- 28. UIView水效果
- 29. 游戏中心如何离线工作?
- 30. 井字游戏 - 如何在无效输入后打印结果