Topic was automatically imported from the old Question2Answer platform.
Asked By
cloa513
I want to a create a lot of objects from a 2D class (don’t move don’t collide) and each has a different individual sprite that never needs to be changed- not changed between each other. Clarification- essentially 9 different sprites later they change their color that is all they do. What is the simplest way to do that? Do I need a sprite array?
Your question is a little bit ambiguous, but here are my thoughts.
Your problem: Want to change sprite color(or other parameters) when adding the sprite instance to the scene.
To do that you need to change parameters (ex: the color of the sprite) of the instance before you use add_child to the scene.
It may looks like this:
var sprite = load("your path")
var color_list = [all color you want]
for i in range(0,9): # or any other loop is ok
var temp_sprite = sprite.instance()
temp_sprite.modulate = color_list[i]
add_child(temp_sprite)
Not my question- at instantiation choose one sprite for the object (900 objects to create). Simplest way to do that. No tutorials that I have seen cover that.