简体   繁体   中英

how to get height of an entity in ursina?

I'm making a Brick Breaker Game using Ursina in python. 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. Like this:

我的想象力

For this I want the width and height of the bar. How can I get that? I tried 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 .

For more options you can check https://www.ursinaengine.org/api_reference and see Entity ( https://www.ursinaengine.org/api_reference#Entity )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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