小编Cri*_*tes的帖子

Lua“类”的两个实例是同一个“对象”

我正在使用 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)

lua love2d

3
推荐指数
1
解决办法
249
查看次数

如何在 Flutter 中居中两个文本

我有下一个小部件:

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”文本的样式,但我还没有设法使它工作(像图像一样居中两个文本),我正在尝试使用一行,更多的容器,中心班等

flutter flutter-layout

2
推荐指数
2
解决办法
7390
查看次数

标签 统计

flutter ×1

flutter-layout ×1

love2d ×1

lua ×1