当我运行代码时,它说:
: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()
这是我使用的程序。我尝试使用快速修复,但过了一段时间后,它不适用于这个问题。此外,无论多少次更正标记变成绿色,我点击运行它仍然说属性错误,我不知道我做错了什么。
1条答案
按热度按时间nfzehxib1#
您似乎拼错了
super().__init__()
。请尝试以下操作:我将
super().__innit(
更改为super().__init__(