Moai网格与瓷砖颜色
发布时间:2020-12-14 21:47:43 所属栏目:大数据 来源:网络整理
导读:我正在尝试使用Moai SDK为游戏创建网格.网格中的每个图块都应该能够填充颜色. 所以实际上我有两个问题: 使用Moai构建网格的最佳方法是什么? 如何用颜色单独填充每个瓷砖 谢谢 解决方法 What is the best way to build a grid using Moai Moai有一个创建网
我正在尝试使用Moai SDK为游戏创建网格.网格中的每个图块都应该能够填充颜色.
所以实际上我有两个问题: >使用Moai构建网格的最佳方法是什么? 谢谢 解决方法
Moai有一个创建网格的对象:MOAIGrid.使用框架
A Moai deck是图像或图像集合.如果你想要你的 例 此代码将在窗口中创建一个4×4网格: -- Open the window and create a viewport MOAISim.openWindow("Example",512,512) viewport = MOAIViewport.new() viewport:setSize(512,512) viewport:setScale(512,512) -- Create a layer layer = MOAILayer2D.new() layer:setViewport(viewport) MOAISim.pushRenderPass(layer) -- Create a 4x4 grid of 64x64px squares grid = MOAIGrid.new() grid:initGrid(4,4,64) grid:setRow(1,1,1) grid:setRow(2,1) grid:setRow(3,1) grid:setRow(4,1) -- Load the image file deck = MOAITileDeck2D.new() deck:setTexture("squares.png") deck:setSize(2,2) -- Make a prop with that grid and image set prop = MOAIProp2D.new() prop:setDeck(deck) prop:setGrid(grid) prop:setLoc(-256,-256) -- Add it to the layer so it will be rendered layer:insertProp(prop) 之后,如果要更改特定单元格的颜色,请使用 -- Change the color of cell 1,1 to the second item in the deck grid:setTile(1,2) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |