gpt4 book ai didi

iphone - 《水果忍者》游戏中的切片效果如何发挥作用?

转载 作者:行者123 更新时间:2023-12-03 21:20:55 26 4
gpt4 key购买 nike

有人知道水果忍者游戏中的切片效果是如何工作的吗?

screenshot of Fruit Ninja game

或者有其他方法可以达到类似的效果吗?

如何获得所有滑动点以及如何在其上画线请帮忙....

最佳答案

我画了很多条线来产生切片效果,并同时从我放置点来画线的可变数组中删除点

代码:-

-(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];
}

关于iphone - 《水果忍者》游戏中的切片效果如何发挥作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4943938/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com