我正在使用 Love2d 和 Lua,看看我的自定义 Lua“类”:
-- Tile.lua
local Tile = { img = nil, tileType = 0, x = 0, y = 0 }
function Tile:new (img, tileType, x, y)
o = {}
setmetatable(o, self)
self.__index = self
self.img = img or nil
self.tileType = tileType or 0
self.x = x or 0
self.y = y or 0
return o
end
function Tile:getX ()
return self.x
end
return Tile
Run Code Online (Sandbox Code Playgroud)
并使用该类:
-- main.lua
Tile = require("src/Tile")
function love.load()
myGrass = Tile:new(nil, …
Run Code Online (Sandbox Code Playgroud) 我有下一个小部件:
class PoinstsDisplayState extends State<PoinstsDisplay> {
@override
Widget build(BuildContext context) {
return new Container(
width: MediaQuery.of(context).size.width*0.9,
margin: EdgeInsets.only(top: 20.0),
padding: EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: Color(0xff2b2b2b),
borderRadius: BorderRadius.circular(10.0),
),
child: new Text(
'5000 Pts',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20.0,
fontFamily: 'Karla'
),
)
);
}
}
Run Code Online (Sandbox Code Playgroud)
看起来像这样:
有完美的位置,现在我想分别设置数字 5000 和“Pts”文本的样式,但我还没有设法使它工作(像图像一样居中两个文本),我正在尝试使用一行,更多的容器,中心班等