我是iphone开发游戏(也是新软件开发领域)的新手。我需要开发像Ninga,veg samurai和cut cut boom games这样的切割效果。我不知道怎么做。我不知道如何做到这一点。搜索很多,他们说只是找到距离和角度向量,然后将其应用到4x4矩阵...(或)他们说使用openGL来开发这样的函数......就像他们说的,我使用openGL绘制但是看起来不像那样。任何人都可以帮忙做到这一点....给出开发切割效果的示例代码....提前致谢....
这是我的绘图功能,方便您使用..... - (无效)平局 {
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);
}
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];
}
我的更新功能淡出了这一行 - (void)更新:(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;
}
}
答案 0 :(得分:0)
查看代码,我看到了几个问题。我会退一步,开始更基本的。 “前沿”的问题在于它们通常由先进的人完成,可以创造新的,令人敬畏的东西,因此是最前沿的。我可以推荐一本关于游戏开发的书吗? Apress: Beginning iPhone Games Development是一本很好的读物。