"circles" is a list with the objects of the class. Each object has 2 attributes: picture and position, so in "i.img pos i.pos" I just specify which picture to take and where to place it.
Code: Select all
for i in circles:
draggroup:
drag:
image i.img pos i.pos
drag_name i
drag_raise TrueCode: Select all
draggroup:
drag:
image img
drag:
image img
drag:
image imgSo it should work by default until I set drag_raise = False
I'm wondering what's going on here?
Code: Select all
drag:
img # ?If I use:
Code: Select all
draggroup:
drag:
img class Drag(DragGroup) ?
But I don't understand how I can refer to Drag and DragGroup instances. I don't know the names of these instances.
Perhaps can somehow explicitly specify the attribute "top = True" or call the method "raise_children" for each active object?
Code: Select all
init python:
circles = []
class Circle:
def __init__(self, img, pos):
self.img = img
self.pos = pos
def create_circles(c, x, y, z):
for i in range(3):
for k in range(4):
circles.append(Circle(c, (x, y)))
x += field_block * 2
y += field_block
x = start_pos if i != z else offset_x
def draw_obj():
b = Transform('images/black.png', size=(img_sizes)
w = Transform('images/white.png', size=(img_sizes)
circles.clear()
create_circles(b, start_pos, start_pos, 0)
create_circles(w, offset_x, start_white_pos_y, 1)
screen:
$ draw_obj()
frame:
for i in circles:
fixed:
drag:
child i.img pos i.pos
drag_name i
drag_raise TrueI also call the function for creating objects 2 times (white and black figures). It turns out that all objects that were created in the second function (white shapes) overlap those created in the first function (black shapes).
But that shouldn't matter, because in the function I just create instances of the class and give them parameters: an image and a position. Then I put them in one common list.
Then I draw pictures in the loop and take the picture of the desired color and position from the common list. But I don't understand why the objects created in the second function (white) are dominant... as if they get into 2 different DragGroups. Maybe different pictures are in different groups?