Skip to content

Instantly share code, notes, and snippets.

View jshorty's full-sized avatar

Jake Shorty jshorty

View GitHub Profile
@jshorty
jshorty / snapshot_sprite.gd
Created April 5, 2020 08:29
Sprite that "snapshots" a Polygon2D for rendering performance
extends Sprite
# This dictates the size of the viewport used for the "snapshot".
export var source_image_size : Vector2
export var polygon : PoolVector2Array
func _ready():
var viewport_container = ViewportContainer.new()
viewport_container.set_size(source_image_size)
add_child(viewport_container)
@jshorty
jshorty / flickering_node.gd
Last active January 26, 2020 04:59
GDScript snippet for a flickering Node
var _flicker_timer
func _ready():
_flicker_timer = get_tree().create_timer(0.0)
# n: number of times to flicker
# s: time (sec) each flicker takes
func flicker(n = 0, s = 0.1):
var toggles = int(n * 2)
if toggles % 2 == 0: