I need to develop cutting effect like in fruit ninga,veg samurai game in iphone
I am new to developing games (and also i am new software development field) in iphone.I need to develop cutting effect like in fruit Ninga , veg samurai and cut cut boom games.I dont know how to do this.I search lot about that, they say just find the distance and angle vector ,then apply it to the 4x4 matrix...(or) they said use openGL to develop function like this...Like they said, i use openGL to draw but it doesn't look like that.can anyone help to do that.... give sample code for developing cutting effect ....Thanks in advance....
Here is my draw function for ur convenience..... -(void) draw {
if([_points count] > 0)
{
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_LINE_SMOOTH);
glColor4f(20, 20, 20, 20);
for(int i=0;i<[_points count]-1;i++)
{
if(i<=1)
{
glLineWidth(5.0f);
MovePoints *p1 = (MovePoints*)[_points objectAtIndex:i];
MovePoints *p2 = (MovePoints*)[_points objectAtIndex:i+1];
ccDrawLine(p1.location,p2.location);
}
if(i>1 && i<=2)
{
glLineWidth(5.5f);
MovePoints *p1 = (MovePoints*)[_points objectAtIndex:i];
MovePoints *p2 = (MovePoints*)[_points objectAtIndex:i+1];
ccDrawLine(p1.location,p2.location);
}
if(i>2 && i<=3)
{
glLineWidth(6.0f);
MovePoints *p1 = (MovePoints*)[_points objectAtIndex:i];
MovePoints *p2 = (MovePoints*)[_points objectAtIndex:i+1];
ccDrawLine(p1.location,p2.location);
}
if(i>3 && i<=4)
{
glLineWidth(7.0f);
MovePoints *p1 = (MovePoints*)[_points objectAtIndex:i];
MovePoints *p2 = (MovePoints*)[_points objectAtIndex:i+1];
ccDrawLine(p1.location,p2.location);
}
if(i>4 && i<=5)
{
glLineWidth(8.0f);
MovePoints *p1 = (MovePoints*)[_points objectAtIndex:i];
MovePoints *p2 = (MovePoints*)[_points objectAtIndex:i+1];
ccDrawLine(p1.location,p2.location);
}
if(i>5 && i<=6)
{
glLineWidth(9.0f);
MovePoints *p1 = (MovePoints*)[_points objectAtIndex:i];
MovePoints *p2 = (MovePoints*)[_points objectAtIndex:i+1];
ccDrawLine(p1.location,p2.location);
}
if(i>6 && i<=7)
{
glLineWidth(10.0f);
MovePoints *p1 = (MovePoints*)[_points objectAtIndex:i];
MovePoints *p2 = (MovePoints*)[_points objectAtIndex:i+1];
ccDrawLine(p1.location,p2.location);
}
if(i>7 && i<=8)
{
glLineWidth(11.0f);
MovePoints *p1 = (MovePoints*)[_points objectAtIndex:i];
MovePoints *p2 = (MovePoints*)[_points objectAtIndex:i+1];
ccDrawLine(p1.location,p2.location);
}
if(i>8 && i<=9)
{
glLineWidth(12.0f);
MovePoints *p1 = (MovePoints*)[_points objectAtIndex:i];
MovePoints *p2 = (MovePoints*)[_points objectAtIndex:i+1];
ccDrawLine(p1.location,p2.location);
}
if(i>9 && i<=10)
{
glLineWidth(13.0f);
MovePoints *p1 = (MovePoints*)[_points objectAtIndex:i];
MovePoints *p2 = (MovePoints*)[_points objectAtIndex:i+1];
ccDrawLine(p1.location,p2.location);
开发者_C百科 }
if(i>10 && i<=11)
{
glLineWidth(14.0f);
MovePoints *p1 = (MovePoints*)[_points objectAtIndex:i];
MovePoints *p2 = (MovePoints*)[_points objectAtIndex:i+1];
ccDrawLine(p1.location,p2.location);
}
if(i>11 && i<=12)
{
glLineWidth(15.0f);
MovePoints *p1 = (MovePoints*)[_points objectAtIndex:i];
MovePoints *p2 = (MovePoints*)[_points objectAtIndex:i+1];
ccDrawLine(p1.location,p2.location);
}
if(i>12 && i<=13)
{
glLineWidth(16.0f);
MovePoints *p1 = (MovePoints*)[_points objectAtIndex:i];
MovePoints *p2 = (MovePoints*)[_points objectAtIndex:i+1];
ccDrawLine(p1.location,p2.location);
}
}
[super draw];
}
And my update function for fade out the line - (void) update:(ccTime) dt { double now = [[NSDate date] timeIntervalSince1970];
if(lastTimeTrailRemoved == 0)
{
lastTimeTrailRemoved = now;
return;
}
if(((now - lastTimeTrailRemoved) > 0.03f) && ([_points count] > 0))
{
NSLog(@"removing last point");
[_points removeObjectAtIndex:0];
[_points removeObjectAtIndex:1];
[_points removeObjectAtIndex:2];
[_points removeObjectAtIndex:3];
lastTimeTrailRemoved = now;
}
}
Looking over your code, I see several issues. I would take a step back and start more basic. The problem with 'cutting edge' is they are generally done by people who are advanced and can create new, awesome stuff, hence cutting edge. Might I recommend a book on games development? Apress: Beginning iPhone Games Development is a good read.
精彩评论