Skip to content

A script to create "sprites" using the _draw() function to easily create patterns, change the color palette, or change the pixel size.

License

Notifications You must be signed in to change notification settings

hiulit/Godot-3-2D-Draw-Sprite

Repository files navigation

Godot 3 2D Draw Sprite

Godot v3.x release v1.0.0 MIT license

A script to create "sprites" using the _draw() function to easily create patterns, change the color palette, or change the pixel size.

The variables _sprite and _colors are created using Aseprite to Godot variables.

Godot 3 2D Draw Sprite banner

Table of contents

Variables

Name Type Default
sprite Array _sprite
colors PoolColorArray _colors
repeat Vector2 Vector2.ONE
pixel_size int 1
offset Vector2 Vector2.ZERO

Variables

sprite

export(Array, Array, int) var sprite = _sprite setget _set_sprite

A 2D array with the indices of the colors array.

It can have null values (those will be completely transparent pixels).

Name Type Default Setter
sprite Array _sprite _set_sprite

Example:

var _sprite = [
  [0,0,0,0,0,0,0,1,1,0,0,],
  [0,0,0,0,1,1,0,1,1,1,0,],
  [0,0,1,0,1,1,0,1,1,1,0,],
  [0,1,1,0,0,1,0,0,0,0,0,],
  [1,1,1,1,0,0,0,0,0,0,0,],
  [0,1,1,1,0,0,0,1,1,0,0,],
  [0,0,1,0,0,1,1,1,1,0,0,],
  [0,1,1,1,1,1,1,0,0,1,1,],
  [1,1,1,1,1,1,1,0,1,1,1,],
]

colors

export(PoolColorArray) var colors = _colors setget _set_colors

The colors of the sprite.

Name Type Default Setter
colors PoolColorArray _colors _set_colors

Example:

var _colors = PoolColorArray([
  Color(1.0,0.63,0.0,1.0),
  Color(0.67,0.32,0.21,1.0),
])

repeat

export(Vector2) var repeat = Vector2.ONE setget _set_repeat

The amount of times each sprite is repeated on the X and Y axis.

Useful to create a pattern.

Name Type Default Setter
repeat Vector2 Vector2.ONE _set_repeat

pixel_size

export(int) var pixel_size = 1 setget _set_pixel_size

A multiplier to increase the size of the sprite.

Name Type Default Setter
pixel_size int 1 _set_pixel_size

offset

export(Vector2) var offset = Vector2.ZERO setget _set_offset

The amount of extra pixels of the sprite from its original position.

Name Type Default Setter
offset Vector2 Vector2.ZERO _set_offset

πŸ—’οΈ Changelog

See CHANGELOG.

πŸ‘€ Author

  • hiulit

🀝 Contributing

Feel free to:

πŸ™Œ Supporting this project

If you find this project helpful, please consider supporting it through any size donations to help make it better.

Become a patron

Suppor me on Ko-Fi

Buy me a coffee

Donate Paypal

If you can't, consider sharing it with the world...

Share on Twitter

... or giving it a star.

Thank you very much!

πŸ“ Licenses


Powered by GDScriptify.

About

A script to create "sprites" using the _draw() function to easily create patterns, change the color palette, or change the pixel size.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published