[英]Attribute error when using ursina and making texturebox()
當我運行代碼時,它說:
:prc(warning): Invalid integer value for ConfigVariable win-size: 864.0
:prc(warning): Invalid integer value for ConfigVariable win-size: 1536.0
Known pipe types:
wglGraphicsPipe
(3 aux display modules not yet loaded.)
:prc(warning): changing default value for ConfigVariable paste-emit-keystrokes from '1' to '0'.
:pnmimage:png(warning): iCCP: known incorrect sRGB profile
Traceback (most recent call last):
File "C:\Users\LENOVO\PycharmProjects\pythonProject\main.py", line 37, in <module>
TextureBox()
File "C:\Users\LENOVO\PycharmProjects\pythonProject\main.py", line 18, in __init__
super().__innit(
^^^^^^^^^^^^^^^
AttributeError: 'super' object has no attribute '_TextureBox__innit'
Process finished with exit code 1
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
app = Ursina()
for z in range(10):
for x in range(10):
Entity(
model="cube", color=color.dark_gray, collider="box", ignore=True,
position=(x, 0, z),
parent=scene,
origin_y=0.5,
text="white_cube"
)
class TextureBox(Button):
def __init__(self, position=(5, 2, 5)):
super().__innit(
parent=scene,
position=position,
model="cube",
origin_y=0.5,
texture="texture.jpg",
color=color.color(0, 0, 1)
)
self.texture_choice = 0
self.textures = ["texture.jpg", "wood.jpg", "stones.jpg", "blue.jpg"]
def input(self, key):
if self.hovered:
if key == 'left mouse down':
self.texture_choice += 1
self.texture_choice %= len(self.textures)
self.texture = self.textures[self.texture_choice]
TextureBox()
player = FirstPersonController()
這是我使用的程序。 我嘗試使用快速修復,但一段時間后它不適用於問題。 也不管修正標記變綠多少次,我點擊運行它仍然說屬性錯誤,我不確定我做錯了什么。
看來你拼錯了super().__init__()
。 試試這個:
class TextureBox(Button):
def __init__(self, position=(5, 2, 5)):
super().__init__(
parent=scene,
position=position,
model="cube",
origin_y=0.5,
texture="texture.jpg",
color=color.color(0, 0, 1)
)
self.texture_choice = 0
self.textures = ["texture.jpg", "wood.jpg", "stones.jpg", "blue.jpg"]
def input(self, key):
if self.hovered:
if key == 'left mouse down':
self.texture_choice += 1
self.texture_choice %= len(self.textures)
self.texture = self.textures[self.texture_choice]
我將super().__innit(
更改為super().__init__(
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.