CosCos-android 代碼總結

來源:互聯網
上載者:User

 直接上代碼:

MainActivity中Cocos常規寫法:

CCGLSurfaceView view = = CCGLSurfaceView( CCDirector director = director.setDisplayFPS( director.setAnimationInterval(1/30 CCScene scene = GameLayer gameLayer = View Code

繼承了CCLayer的圖層類的基本寫法:

GameLayer player = CCSprite.sprite("tank_a.png" CGPoint point = CGPoint.ccp(100, 100 CGPoint target = CGPoint.ccp(400, 100= CCJumpTo.action(3,target,200,10View Code

 繼承了CCLayer的圖層類的幾個動作:精靈移動 旋轉 縮放到指定倍數 閃爍 隱藏(CCHide) 顯示

player = CCSprite.sprite("tank_a.png"100, 100 View Code

繼承了CCLayer的圖層類的動作執行方式:動作依次執行 多個動作同時執行 以及精靈清理技巧

playerA = CCSprite.sprite("tank_a.png"= CCSprite.sprite("tank_b.png"= CGPoint.ccp(100,100= CGPoint.ccp(300, 300= CCMoveTo.action(2= CCRotateTo.action(2,90= CCScaleTo.action(2, 2 "onActionFinished called"View Code

繼承了CCLayer的圖層類的向量的加、減、乘:

playerA = CCSprite.sprite("tank_a.png"= CCSprite.sprite("tank_b.png"= CGPoint.ccp(0, 400= CGPoint.ccp(200, 300 View Code

繼承了CCLayer的圖層類的 精靈淡入(顏色變化到指定值、顏色變化到相對值) 精靈淡出 重複指定動作N次數 指定動作,重複次數無限

playerA = CCSprite.sprite("tank_a.png"= CGPoint.ccp(100,300 View Code

繼承了CCLayer的圖層類的 觸摸事件

System.out.println("began" x = y == CGPoint p3="轉換後:"+p3.x+","+"轉換前:("+x+","+y+") = end" System.out.println("move" .setIsTouchEnabled(= CCSprite.sprite("tank_a.png"View Code

繼承了CCLayer的圖層類的 按時間執行指定函數

GameLayer_Time .setIsTouchEnabled( .schedule("fun", 2 fun("fun is called"+ .unschedule("fun""unschedule" View Code

註:其中圖片資源要放在這此只是基本的用法,其它的用法 還要看源碼。

要源範例程式碼的請頂起!

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.