python中int对象不可调用_在python中使用类时获取“TypeError:”int“对象不可调用”...

我在python中使用了一个类(我在这个程序中也使用了pygame),但是它不允许我调用这个特定的方法。这个班叫做“敌人”。

这是问题解决方法:def attack(self, screen):

self.charx = self.screen.get_width()/2 - self.pic.get_width()/2

self.chary = self.screen.get_height()/2 - self.pic.get_height()/2

textbox(self.screen, self.charx - self.c.rect.x + self.rect.x, self.chary - self.c.rect.y + self.rect.y, 15, 5, True, (255, 255, 255), True, (0, 0, 0), 0, '', True, (255, 0, 0), 15*self.healthpercent)

if self.rect.colliderect(self.w.rect):

if self.agility*random.randint(1, 10) > self.c.agility*random.randint(1, 10):

self.c.health -= self.level*5

if self.agility*random.randint(1, 10) <= self.c.agility*random.randint(1, 10):

self.health -= self.w.weaponpower*self.c.strength

self.healthpercent = self.health/self.level*100

if self.health == 0:

self.dead = True

我这样称呼它:

^{pr2}$

显然有些变量名等是在别处定义的,但我不认为这些位是必要的。

这是完整的堆栈跟踪:Traceback (most recent call last):

File "E:\Code\Game\Main6.py", line 119, in

e.attack(screen)

TypeError: 'int' object is not callable

>>>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值