This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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?

Godot version 3.3.4
in Engine by (54 points)

1 Answer

0 votes

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)
by (345 points)

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.