You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def create_enemy(total, where):
n = 0
while n < total:
n = n + 1
enemy = Enemy()
enemy.push_handlers(where)
random_x = random.randint(0, 640)
position = random_x, 240
enemy.show_at(position)
time.sleep(1)
lass Enemy(pyglet.event.EventDispatcher):
def init(self):
self.life = 10
self.position = 0, 0
Enemy.register_event_type('on_enemy_born')
Enemy.register_event_type('on_enemy_under_attack')
Enemy.register_event_type('on_enemy_destroyed')
class BattleField(cocos.layer.Layer):
def init(self):
super(BattleField, self).init()
def create_enemy(total, where):
n = 0
while n < total:
n = n + 1
enemy = Enemy()
enemy.push_handlers(where)
random_x = random.randint(0, 640)
position = random_x, 240
enemy.show_at(position)
time.sleep(1)
if name == "main":
cocos.director.director.init()
bg_layer = BackGround()
battle_field_layer = BattleField()
thread = threading.Thread(target=create_enemy, args=(10, battle_field_layer))
thread.start()
main_scene = cocos.scene.Scene(bg_layer, battle_field_layer)
cocos.director.director.run(main_scene)
Above is my code,I am trying to add enemy dynamic from other thread. It keep raising the GLException.
The text was updated successfully, but these errors were encountered: