# cars01 **Repository Path**: linuxing3/cars01 ## Basic Information - **Project Name**: cars01 - **Description**: quick-cocos2d-x - **Primary Language**: Lua - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2014-04-03 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # # Quick-Cocos2d ## 配置游戏导演Director ## 设计一个场景Scene ## 添加一个图层Layer local layer1 = display.NewLayer() self:addChild(layer1) ## 添加一个节点Node或精灵Sprite Local sprite = display.NewSprite() local group = display.newNode() -- 创建一个容器 group:addChild(sprite1) -- 添加显示对象到容器中 group:addChild(sprite2) -- 添加显示对象到容器中   -- 移动容器时,其中包含的子对象也会同时移动 transition.moveBy(group, {time = 2.0, x = 100}) ## 批量添加节点BatchNode local imageName = "Sprites.png" display.addSpriteFramesWithFile("Sprites.plist", imageName) -- 载入图像到帧缓存   -- 下面的代码绘制 100 个图像只用了 1 次 OpenGL draw call local batch = display.newBatch(imageName) for i = 1, 100 do local sprite = display.newSprite("#Sprite0001.png") batch:addChild(sprite) end ## 创建一个类 ### Define the object with class and it's method separately local Car = class("car",function() return sprite ) local car:move() end return Car ### in where you want to use this class local Car = require(class.Car) local aCar = Car.new() aCar:move() self:add(aCar) ### use data definition a table/class/object local Data={} Data[1] = { rows = 4, cols = 4, grid = { {0, 1, 1, 0}, {0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0} } } print(Data[1]["rows"]) print(Data[1]["grid"][1][1])