SpriteKit and UIKit compatibility: OpenGL error when migrating to Swift 2?

匆匆过客 提交于 2019-12-08 02:45:00

问题


I just don't understand what is going on since I migrated to Swift 2. I have a Tabbed application and I am getting this error:

<CAEAGLLayer: 0x7fb2e053fb40>: calling -display has no effect.
Assertion failed: (length + offset <= _length), function commit_data, 
file /BuildRoot/Library/Caches/com.apple.xbs/Sources/Jet_Sim/Jet-1.50/Jet/jet_types_OpenGL.h, line 863.

I know it is really vague but I don't know where to start looking for bugs. Thanks.

Edit: I just realized it might be related to the fact that I am trying to embed a GameViewController into the TabbedController. However, it did not cause any error before iOS 9.0. Any clue?


回答1:


Ok, so the problem was with SKShapeNode. I was drawing ring portions with too many vertices. By decreasing the number of steps in the following function, the problem disappeared!!

func drawPortion2(r1:CGFloat, r2:CGFloat, angle1:CGFloat, angle2:CGFloat, fillColor:UIColor, steps:Int)->SKShapeNode{
let vertices=UnsafeMutablePointer<CGPoint>.alloc(2*steps);
let stepsF=CGFloat(steps);

for j in 0..<steps{

    vertices[j]=CGPoint(x: r2*cos(angle2-CGFloat(j)*(angle2-angle1)/stepsF), y: r2*sin(angle2-CGFloat(j)*(angle2-angle1)/stepsF));

}

for j in 0..<steps {

    vertices[steps+j]=CGPoint(x: r1*cos(angle2-CGFloat(steps-j)*(angle2-angle1)/stepsF), y: r1*sin(angle2-CGFloat(steps-j)*(angle2-angle1)/stepsF));

}

let portion=SKShapeNode(points:vertices, count: 2*steps);
//portion.position=centerPos;
portion.fillColor=fillColor;

return portion;

}


来源:https://stackoverflow.com/questions/32677503/spritekit-and-uikit-compatibility-opengl-error-when-migrating-to-swift-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!