Cocos2dx lua 3D實例代碼

用cocoside 建立一個項目 cocos2dx lua 項目便可 ,而後替換掉gamescene 就能夠,具體效果還有函數的參數,相信你們一看就明白。簡單說下ide 建立的php

cocos lua 項目 和cocos quick 項目的區別。cocos lua項目就是簡單的一個沒有帶quick框架的項目,在src目錄下沒有framwork目錄(這裏面在quick項目有,是別人寫好的一個框架)html

能夠直接用IDE打包。cocos quick 項目就是包含了別人開發的quick框架。暫時右鍵沒有直接打包的方法。,,,我是用的eclipse打包node

注:Eclipse打包(除了配置以前的Java sdk ndk ant 等,在properties項目屬性裏面的android

builders 中配置ndk 和res 。框架

ndk在 android-ndk-r9d\ndk-build.cmd。eclipse

res在本項目下,${workspace_loc:/AppActivity/build_native.bat})ide

  1 local GameScene = class("GameScene",function()
  2     return cc.Scene:create()
  3 end)
  4 
  5 function GameScene.create()
  6     local scene = GameScene.new()
  7     return scene
  8 end
  9 
 10 --*****************************************************************--
 11 --3D晃動的特效
 12 local shaky3d = function () 
 13     return cc.Shaky3D:create(5.0,cc.size(50,50),15,false)
 14 end
 15 --3D瓷磚晃動特效
 16 local shakyTiles3D = function ()
 17     return cc.ShakyTiles3D:create(5.0,cc.size(200,200),2,false)
 18 end
 19 
 20 local wave = function()
 21     return cc.Waves:create(5, cc.size(10, 10), 10, 20, true, true)
 22 end
 23 
 24 --3D水波紋特效 CCWaves3D
 25 local waves3D = function()
 26     return cc.Waves3D:create(5, cc.size(10, 10), 10, 20)
 27 end
 28 
 29 --3D瓷磚波動特效 
 30 local wavesTiles3D = function()
 31     return cc.WavesTiles3D:create(5, cc.size(10, 10), 10, 20)
 32 end
 33 
 34 --X軸 3D反轉特效 
 35 local filpX = function()
 36     return cc.FlipX:create(5)
 37 end
 38 
 39 --Y軸3D反轉特效
 40 local filpY = function()
 41     return cc.FlipY:create(5)
 42 end
 43 
 44 --凸透鏡特效
 45 local lens3D = function()
 46     return cc.Lens3D:create(2, cc.size(10, 10),cc.p(240, 160), 240)
 47 end
 48 
 49 --水波紋特效 
 50 local ripple3D = function()
 51     return cc.Ripple3D:create(5, cc.size(10, 10), cc.p(240, 160), 240, 4, 160)
 52 end
 53 
 54 --液體特效
 55 local liquid = function()
 56     return cc.Liquid:create(5, cc.size(10, 10), 4, 20)
 57 end
 58 
 59 --扭曲旋轉特效  
 60 local twirl = function()
 61     return cc.Twirl:create(50, cc.size(10, 10), cc.p(240, 160), 2, 2.5)
 62 end
 63 
 64 --破碎的3D瓷磚特效  
 65 local shatteredTiles3D = function()
 66     return cc.ShatteredTiles3D:create(15, cc.size(10, 10), 50, true)
 67 end
 68 
 69 --瓷磚洗牌特效  
 70 local shuffle = function()
 71     return cc.ShuffleTiles:create(5, cc.size(50, 50), 50)
 72 end 
 73 
 74 --部落格效果,從左下角到右上角  
 75 local fadeOutTRTiles = function()
 76     return cc.FadeOutTRTiles:create(5, cc.size(50, 50))
 77 end 
 78 
 79 --摺疊效果 從下到上  
 80 local fadeOutUpTiles = function()
 81     return cc.FadeOutUpTiles:create(5, cc.size(10, 10))
 82 end 
 83 
 84 --摺疊效果,從上到下  
 85 local fadeOutDownTiles = function()
 86     return cc.FadeOutDownTiles:create(5, cc.size(20, 50))
 87 end
 88 
 89 --方塊消失特效  
 90 local turnOffFiels = function()
 91     return cc.TurnOffTiles:create(5, cc.size(50, 50))
 92 end
 93 
 94 --跳動的方塊特效  
 95 local jumpTiles3D = function()
 96     return cc.JumpTiles3D:create(5, cc.size(20, 20), 5, 20)
 97 end
 98 
 99 --分多行消失特效  
100 local splitCols = function()
101     return cc.SplitCols:create(5,50)
102 end
103 
104 --分多列消失特效  
105 local splitRows = function()
106     return cc.SplitRows:create(5,50)
107 end 
108 
109 --3D翻頁特效  
110 local pageTurn3D = function()
111     return cc.PageTurn3D:create(5,cc.size(20,20))
112 end 
113 --*****************************************************************--
114 
115 local ActionList = {
116     shaky3d,
117     shakyTiles3D,
118     wave,
119     waves3D,
120     wavesTiles3D,
121     lens3D,
122     ripple3D,
123     liquid,
124     twirl,
125     shatteredTiles3D,
126     shuffle,
127     fadeOutTRTiles,
128     fadeOutUpTiles,
129     fadeOutDownTiles,
130     turnOffFiels,
131     jumpTiles3D,
132     splitCols,
133     splitRows,
134     pageTurn3D,
135 }
136 
137 local ActionListName = {
138     '3D晃動的特效:Shaky3D',
139     '3D瓷磚晃動特效:ShakyTiles3D',
140     '波動特效:Waves',
141     '3D水波紋特效 Waves3D',
142     '3D瓷磚波動特效 :WavesTiles3D',
143     '凸透鏡特效:Lens3D',
144     '水波紋特效 :Ripple3D',
145     '液體特效:Liquid',
146     '扭曲旋轉特效:Twirl',
147     '破碎的3D瓷磚特效  :ShatteredTiles3D',
148     '瓷磚洗牌特效:ShuffleTiles',
149     '部落格效果,從左下角到右上角  :fadeOutTRTiles',
150     '摺疊效果 從下到上  :fadeOutUpTiles',
151     '摺疊效果,從上到下  :fadeOutDownTiles',
152     '方塊消失特效:TurnOffTiles',
153     '跳動的方塊特效  :JumpTiles3D',
154     '分多行消失特效  :SplitCols',
155     '分多列消失特效:splitRows ',
156     '3D翻頁特效 :PageTurn3D'
157 
158 }        
159 function GameScene:ctor()
160 
161     self.visibleSize = cc.Director:getInstance():getVisibleSize()
162     self.origin = cc.Director:getInstance():getVisibleOrigin()
163     
164     local sprite = cc.Sprite:create("card.png")
165     sprite:setPosition(240,160)
166     local nodegird = cc.NodeGrid:create()
167     nodegird:addChild(sprite)
168     self:addChild(nodegird)
169     
170     self._nodegird = nodegird 
171     self.currentId = 1
172     
173     local function changeAction()
174         if self.currentId > #ActionList then
175             self.currentId = 1
176         end
177         self._nodegird:stopAllActions()
178         local fun = ActionList[self.currentId]
179         local actionInterval = fun()
180         self._nodegird:runAction(actionInterval)
181         self._nameLabel:setString(ActionListName[self.currentId])
182         self.currentId = self.currentId + 1  
183     end
184  
185     local menuRun = cc.MenuItemFont:create("ChangeAction")
186     menuRun:setPosition(0, 0)
187     menuRun:registerScriptTapHandler(changeAction)
188     local menu = cc.Menu:create(menuRun)
189     menu:setPosition(400,50)
190     self:addChild(menu,2)
191     
192     
193     local nameLable = cc.Label:create()
194     nameLable:setPosition(100,200)
195     self:addChild(nameLable,6)
196     self._nameLabel = nameLable
197 end
198 
199 return GameScene

 Cocos2dx 中3D的例子,跑酷類demo的實現等函數

http://www.cocoachina.com/bbs/read.php?tid-270738.htmlui

相關文章
相關標籤/搜索