I made 2 lines of squares by copying the sprite “square”. Now I want to color each square in different color. How to refer in Events editor to each copy (instance) of square?
First open the square in an image program such as GIMP and save a copy in each colour you want the squares.
The way to have different colours is to either:
Make a new sprite object for each colour you want (as I did in this game: kongregate.com/games/Matsps/vend-dodge). Obviously then referencing different colour squares is very easy, as they are different sprites.
OR
Make a different animation for each square colour and then you can reference each square colour by the animation it is on.
For each object square
Animation of square = 1 | Do some action
Pffhhh… Why get tired with GIMP when you can do it automagically?
First, you need to enumerate objects. You can do this using object variables. Object variables can be different for each object. Let’s say you have instanceID variable for each square. You change it for every one, so for first square it is 1, for second it is 2 etc.
Now you go to events.
You need for each object loop with “square” object selected. Now in each subevent you check if object variable instanceID = 1, etc. (for each id you need another subevent) and use Change Object Color action where you select color.
GIMP actually has a batch convert operation that makes colouring things automated…
This way you suggest is also horrific. Imagine doing it for only 20 squares. You want to write 20 sub events!
The solution of Matt looks easier for me. I thought about creating sprites of different colors but was just lazy to do it thinking that it would be easier to just color them in GD. I think, I was wrong about it.
Why?
You can iterate trough 20, 157, 2463 or whatever number of instances of the same object from the same function (a function with an iteration loop).
GD already provides those events.