Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python AttributeError:“Fighter”对象没有属性“Fighter”_Python_Python 3.x_Attributes_Super_Attributeerror - Fatal编程技术网

Python AttributeError:“Fighter”对象没有属性“Fighter”

Python AttributeError:“Fighter”对象没有属性“Fighter”,python,python-3.x,attributes,super,attributeerror,Python,Python 3.x,Attributes,Super,Attributeerror,我是新手,我遇到了一个错误,我希望有人能帮助我,解释我的错误 错误: 第178行,在applyThrust中 shipPos=self.Fighter.getPosself.origin AttributeError:“Fighter”对象没有属性“Fighter” 在这种情况下,self是什么?我的意思是,它代表什么样的物体? 我认为错误信息非常有用 def applyThrustself,任务->类战士方法 Fighter->调用Fighter成员或self属性,在本例中,self是Figh

我是新手,我遇到了一个错误,我希望有人能帮助我,解释我的错误

错误:

第178行,在applyThrust中 shipPos=self.Fighter.getPosself.origin AttributeError:“Fighter”对象没有属性“Fighter”


在这种情况下,self是什么?我的意思是,它代表什么样的物体? 我认为错误信息非常有用

def applyThrustself,任务->类战士方法

Fighter->调用Fighter成员或self属性,在本例中,self是Fighter实例


在self.Fighter.setFluidPos中也会出现同样的错误…

我想Mircea想说的是self.Fighter.getPosself.origin中的Fighter是多余的。由于对象是类Fighter,因此self.getPosself.origin应该足够了,因为超类有一个名为getPos的方法,所以您没有显示它的代码

    class Fighter(SphereCollideObj, object):
        fighterCount = 0

        def __init__(self, modelPath, parentNode, nodeName, posVec, traverser, scaleVec = 1.0):
            super(Fighter, self).__init__(modelPath, parentNode, nodeName, 0, 0, 0, 3.0)
            self.modelNode.setScale(scaleVec)
            self.modelNode.setPos(posVec)

            self.trav = traverser

            self.origin = render.attachNewNode("origin")
            self.origin.setPos(0, 0, 0)
            self.origin.hide()

            self.setKeyBindings()

            self.hud = Hud("./Tools/Hud.x", self.modelNode, "Hud", (0, 10, 0))



        def setKeyBindings(self):
            self.accept("space", self.thrust, [1])
            self.accept("space-up", self.thrust, [0])

        def thrust(self,keyDown):
            if keyDown:
                taskMgr.add(self.applyThrust, "thrust")
            else:
                taskMgr.remove("thrust")
                self.acceptOnce("space", self.thrust,[1])
                self.acceptOnce("space-up", self.thrust,[0])
        def applyThrust(self, task):
            shipPos = self.Fighter.getPos(self.origin)
            hudPos = self.hud.modelNode.getPos(self.origin)

            trajectory = hudPos - shipPos
            rate = 5
            trajectory.normalize()
            self.Fighter.setFluidPos(shipPos + trajectory * rate)