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. 井字遊戲 - 如何在無效輸入後打印結果