Skip to content

Commit 4dd62c5

Browse files
committed
added appear() and close() for Entity, which will animate scale for you in a nice way instead of appearing/disappearing instantly.
1 parent dd4f893 commit 4dd62c5

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

taptapir.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,26 @@ class Entity {
781781
)
782782
)
783783
}
784-
shake() {
785784

785+
appear() {
786+
let target_scale_y = this.scale_y
787+
let target_scale_x = this.scale_x
788+
let target_text_alpha = this.text_alpha
789+
this.scale = [0,0]
790+
this.text_alpha = 0
791+
this.enabled = True
792+
this.animate('scale_y', target_scale_y, .25)
793+
after(.25, () => {
794+
this.animate('scale_x', target_scale_x, .5)
795+
this.animate('text_alpha', target_text_alpha, .25)
796+
})
797+
}
798+
close() {
799+
this.animate('text_alpha', 0, .25)
800+
this.animate('scale_y', 0, .25)
801+
after(.25, () => {
802+
this.animate('scale_x', 0, .5)
803+
})
786804
}
787805

788806
fit_to_text() {

0 commit comments

Comments
 (0)