tiled 文本位置居中

This commit is contained in:
YHH
2020-08-15 22:24:08 +08:00
parent 23a45bfd2d
commit 1a2dd9ff2a
5 changed files with 12 additions and 8 deletions

View File

@@ -113,12 +113,14 @@ module es {
obj.textField.size = 12;
obj.textField.fontFamily = "sans-serif";
if (obj.shape){
obj.textField.x = pos.x + (obj.shape.width - obj.textField.width) / 2;
obj.textField.y = pos.y - obj.textField.height - 5;
obj.textField.x = pos.x + (obj.shape.getBounds().width - obj.textField.width) / 2 + obj.shape.getBounds().x;
obj.textField.y = pos.y - obj.textField.height - 5 + obj.shape.getBounds().y;
}else{
obj.textField.x = pos.x + (obj.width - obj.textField.width) / 2;
obj.textField.y = pos.y - obj.textField.height - 5;
}
obj.textField.background = true;
obj.textField.backgroundColor = 0xa0a0a4;
obj.textField.textColor = 0xffffff;
container.addChild(obj.textField);
}