public class MainActivity extends Activity {//繪畫原語測驗
private CCGLSurfaceView mGLSurfaceView;//建立view
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGLSurfaceView = new CCGLSurfaceView(this);//創建surface
setContentView(mGLSurfaceView);//映射view
CCDirector.sharedDirector().attachInView(mGLSurfaceView);//把view給導演類
CCScene scene = CCScene.node();
scene.addChild(new Test1());//創建節點
CCDirector.sharedDirector().runWithScene(scene);//導演開始把圖層上面的元素給view來演
}
private static class Test1 extends CCLayer {//測驗1
private GL10 gl;
public Test1() {
draw(gl);
}
public void draw(GL10 gl) {//一個繪畫類
CGSize s = CCDirector.sharedDirector().winSize();//還是得到螢屏大小
CCDrawingPrimitives.ccDrawLine(gl, CGPoint.ccp(0, 0), CGPoint.ccp(s.width, s.height));//運用繪畫基元來畫線
}
}
}
謝謝大家
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/75803.html
標籤:Cocos2d-x
上一篇:STEAM里的GTA5游戲出現的問題 求解決!!!!!!!!!!!!!
下一篇:cocosbuilder圖片加載
