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. ActionScript:水果忍者滑动
- 3. cocos2d水果忍者抛物线数学
- 4. 切换效果不工作
- 5. 喜欢在游戏中的Uilabel效果
- 6. java游戏中的爆炸效果
- 7. iPhone游戏中的声音效果
- 8. 游戏中的跳跃效果
- 9. 实现水的效果(溅)到XNA 4.0游戏
- 10. 游戏如何制作火焰和烟雾效果?
- 11. iphone游戏的灯光效果与cocos2d
- 12. 如何才能达到“Antichamber”游戏中的效果?
- 13. 如何将转换效果添加到我的LibGdx游戏中?
- 14. 雪碧工具包:SKNodes加入动画像水果忍者的屏幕
- 15. 如何在游戏中实现碰撞效果?
- 16. Scriptaculous幻灯片切换效果不工作在IE6
- 17. 如何在Box2d的侧视图Flash游戏中做慢动作效果
- 18. javascript蛇游戏 - 如何移动苹果?
- 19. ios游戏制作蒙版图层效果
- 20. 切换效果
- 21. 使用OpenGL的2D游戏中的3D效果
- 22. 在忍者模板中切换语言
- 23. spritekit游戏中的声音效果开启/关闭
- 24. 宾果游戏逻辑
- 25. 苹果游戏中心的扑克桌
- 26. python中的宾果游戏逻辑
- 27. 香椿水效果
- 28. 下载游戏更新如何工作?
- 29. 在Android游戏中实现物理效果
- 30. 应用变焦效果在cocos2D游戏环境中?