Moai网格与瓷砖颜色

Moai网格与瓷砖颜色,第1张

概述我正在尝试使用Moai SDK为游戏创建网格.网格中的每个图块都应该能够填充颜色. 所以实际上我有两个问题: >使用Moai构建网格的最佳方法是什么? >如何用颜色单独填充每个瓷砖 谢谢 What is the best way to build a grid using Moai Moai有一个创建网格的对象:MOAIGrid.使用框架 行话,你创建一个网格,并给它一个套牌.然后你把它附在一个道 我正在尝试使用Moai SDK为游戏创建网格.网格中的每个图块都应该能够填充颜色.

所以实际上我有两个问题:

>使用Moai构建网格的最佳方法是什么?
>如何用颜色单独填充每个瓷砖

谢谢

解决方法

What is the best way to build a grID using Moai

Moai有一个创建网格的对象:MOAIGrid.使用框架
行话,你创建一个网格,并给它一个套牌.然后你把它附在一个道具上
将道具添加到图层. (该图层还需要附加的视口
到窗口.)

How can I fill each tile indivIDually with a color

A Moai deck是图像或图像集合.如果你想要你的
瓷砖是不同的颜色然后你会创建一个甲板上的图像
这些颜色的正方形.

此代码将在窗口中创建一个4×4网格:

-- Open the window and create a vIEwportMOAISim.openWindow("Example",512,512)vIEwport = MOAIVIEwport.new()vIEwport:setSize(512,512)vIEwport:setScale(512,512)-- Create a layerlayer = MOAILayer2D.new()layer:setVIEwport(vIEwport)MOAISim.pushRenderPass(layer)-- Create a 4x4 grID of 64x64px squaresgrID = 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 filedeck = MOAITileDeck2D.new()deck:setTexture("squares.png")deck:setSize(2,2)-- Make a prop with that grID and image setprop = MOAIProp2D.new()prop:setDeck(deck)prop:setGrID(grID)prop:setLoc(-256,-256)-- Add it to the layer so it will be renderedlayer:insertProp(prop)

之后,如果要更改特定单元格的颜色,请使用
setTile方法选择单元格中使用的套牌中的哪个项目.

-- Change the color of cell 1,1 to the second item in the deckgrID:setTile(1,2)
总结

以上是内存溢出为你收集整理的Moai网格与瓷砖颜色全部内容,希望文章能够帮你解决Moai网格与瓷砖颜色所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1228016.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存