简体   繁体   English

如何获得ursina中实体的高度?

[英]how to get height of an entity in ursina?

I'm making a Brick Breaker Game using Ursina in python.我正在使用 python 中的 Ursina 制作 Brick Breaker 游戏。 I've created some entities which work as ball and bar.我创建了一些用作球和杆的实体。

bar = Entity(model='quad', color=color.blue, position=(4.5, -10, 0), scale=(3, 0.3), collider='box')

ball = Entity(model='sphere', color=color.red, position=(4.5, -9.5, 0), scale=0.25, collider='sphere')

I want the ball at the upper center of the bar without manually setting the x and y value.我希望球位于条形的上部中心,而无需手动设置 x 和 y 值。 Like this:像这样:

我的想象力

For this I want the width and height of the bar.为此,我想要栏的宽度和高度。 How can I get that?我怎样才能得到它? I tried bar.width .我试过bar.width But it returns 'Entity' object has no attribute 'width'但它返回“实体”对象没有属性“宽度”

Yes, it is possible.是的,有可能。 You can use bar.scale_x and bar.scale_y .您可以使用bar.scale_xbar.scale_y

For more options you can check https://www.ursinaengine.org/api_reference and see Entity ( https://www.ursinaengine.org/api_reference#Entity )有关更多选项,您可以查看https://www.ursinaengine.org/api_reference并查看实体 ( https://www.ursinaengine.org/api_reference#Entity )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM