I’m trying to generate random x and y coordinates for a spritenode with scene.
from scene import *
import sound
import random
import math
A = Action
#screen_size = (414.00, 896.00)
class MyScene (Scene):
def setup(self):
self.bubble = SpriteNode('emj:Blue_Circle')
self.x = random.randrange(410)
self.y = random.randrange(890)
self.bubble.position = (self.x, self.y)
self.background_color = 'white'
self.add_child(self.bubble)
def next_location():
for x in range(9999):
self.x = random.randrange(410)
self.y = random.randrange(890)
yield x, y
#self.new_position = self.next_location()
def did_change_size(self):
pass
def update(self):
pass
def touch_began(self, touch):
if touch.location in self.bubble.frame:
self.bubble.remove_from_parent()
self.x = random.randrange(410)
self.y = random.randrange(890)
def touch_moved(self, touch):
pass
def touch_ended(self, touch):
self.add_child(self.bubble)
if __name__ == '__main__':
run(MyScene(), show_fps=False)