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

Hey guys, I'm creating a 2D game where a player (represented by a simple colourful circle using AnimatedSprite) WASD moves around the screen. Player can 'stamp' anywhere on the screen with Spacebar key, and with every stamp, the player's circle increases in size. The look of the 'stamped' result is retrieved from whatever circle colour/size was displayed.

Problem: I dont know how to create that stamped effect that stays permanently on screen throughout the game (so the screen will be filled with random coloured/sized circles at the end). And how do i retrieve data for colour and size?

Thanks everyone for your help!!

in Engine by (14 points)

There may be a more eloquent way to do this, but one method would be by creating a copy of the player's current sprite, and re-parent it to just be another node in the world.

1 Answer

+1 vote

You can to create a canvas (A node ColorRect for example fill with transparent). Then you need a variable Array where you save data to stamps (position, color, size...), then attach script to colorRect and use the signal draw() to draw the stamps

In main script:

var StampsArray = []

func add_stamp(position : Vector2, radius : int, color : Color) -> void:
   var data = {
         "position" = position ,
         "radius"    = radius,
         "color"      = color
    }
   # Append data to array of stamps
   StampsArray.append(data)
   # call function in your colorrect
   $colorRect.update_stamps(StampsArray)

in color rect:

var stamps_array = []

func update_stamps(data : Array):
    stamps_array = data
    update() # Force re-draw (function draw() is called)

func draw() -> void:
    for data in stamps_array:
        draw_circle(data.position, data.radius, data.color)
by (197 points)
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.