Cocos 3 dx入門

1241 ワード

Quick+Cocos 3 dx+luaバージョン、リソースは添付ファイルを参照
local M = class("MainGame")

local camera = nil
function M:ctor()

    -- 
    local mainScene = display.newScene("MainScene")
    -- 3D 
    --3Dlayer Layer 
    local sceneLayer = cc.Layer:create()
    mainScene:addChild(sceneLayer)   
    -- 3DLayer
    local layer3D = cc3.C3DLayer:create()
    -- 
    camera = cc3.C3DCamera:createOrthographic(layer3D:getWidth(), layer3D:getHeight(), 1, -1000, 1000)
    -- 3D layer
    layer3D:get3DScene():addChild(camera)
    layer3D:get3DScene():setActiveCamera(0)
    sceneLayer:addChild(layer3D)
    mainScene.layer3D = layer3D
    
    -- 
    local name,url = "lz","test/lzzl/lz.ckb"
    local role = cc3.C3DSprite:create(name)
    role:loadFromFile(url, true)
    -- : , , , , 
    role:addAnimationClip(name, 0, role:getAnimationFrameCount(), 0, 1.0)
    role:playAnimationClip(name)
    role:setScale(200)
    layer3D:get3DScene():addChild(role)
    
    -- 
    display.replaceScene(mainScene)
end

return M