This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension DispatchQueue { | |
| static func background(delay: Double = 0.0, background: (()->Void)? = nil, completion: (() -> Void)? = nil) { | |
| DispatchQueue.main.async { | |
| background?() | |
| if let completion = completion { | |
| DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: { | |
| completion() | |
| }) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func shake() { | |
| let shake = CABasicAnimation(keyPath: "position") | |
| shake.duration = 0.05 | |
| shake.repeatCount = 2 | |
| shake.autoreverses = true | |
| let fromPoint = CGPoint(x: center.x - 5, y: center.y) | |
| let fromValue = NSValue(cgPoint: fromPoint) | |
| let toPoint = CGPoint(x: center.x + 5, y: center.y) | |
| let toValue = NSValue(cgPoint: toPoint) | |
| shake.fromValue = fromValue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extends Node2D | |
| var image | |
| var should_update_canvas = false | |
| var drawing = false | |
| # Called when the node enters the scene tree for the first time. | |
| func _ready(): | |
| create_image() | |
| update_texture() |
OlderNewer