summaryrefslogtreecommitdiff
path: root/starling/node.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2018-08-28 09:00:16 -0400
committerDavid Thompson <dthompson2@worcester.edu>2018-08-28 09:06:21 -0400
commitb345d228b38cf6d3b5206327d63fe969adc42811 (patch)
tree1f9ce176383ef75e0e1de04431a7c4866d0d0d18 /starling/node.scm
parent1ad377e3cde4011b9c2934c152335293261c3f1d (diff)
node: Add visible? flag.
Diffstat (limited to 'starling/node.scm')
-rw-r--r--starling/node.scm24
1 files changed, 19 insertions, 5 deletions
diff --git a/starling/node.scm b/starling/node.scm
index 4ce46dd..51866d2 100644
--- a/starling/node.scm
+++ b/starling/node.scm
@@ -31,11 +31,14 @@
agenda
booted?
active?
+ visible?
on-boot
on-enter
on-exit
activate
deactivate
+ show
+ hide
update
update*
render
@@ -63,7 +66,10 @@
;; Flips to #t upon first entering a scene.
(booted? #:accessor booted? #:init-form #f)
;; Flips to #t when node is part of current scene.
- (active? #:accessor active? #:init-form #f))
+ (active? #:accessor active? #:init-form #f)
+ ;; Determines whether or not the node and all of its children are
+ ;; rendered.
+ (visible? #:accessor visible? #:init-form #t #:init-keyword #:visible?))
(define (for-each-child proc node)
(for-each proc (children node)))
@@ -97,8 +103,9 @@ the next update represented as a ratio in the range [0, 1]."
"Render NODE and all of its children, recursively.
ALPHA is the distance between the previous update and the next update
represented as a ratio in the range [0, 1]."
- (render node alpha)
- (for-each-child (lambda (child) (render* child alpha)) node))
+ (when (visible? node)
+ (render node alpha)
+ (for-each-child (lambda (child) (render* child alpha)) node)))
(define-method (on-boot (node <node>))
"Perform initialization tasks for NODE."
@@ -136,8 +143,15 @@ represented as a ratio in the range [0, 1]."
(with-agenda (agenda node)
(set! (active? node) #f)
(on-exit node)
- (for-each-child deactivate node)
- (reset-agenda)))
+ (for-each-child deactivate node)))
+
+(define-method (show (node <node>))
+ "Mark NODE as visible."
+ (set! (visible? node) #t))
+
+(define-method (hide (node <node>))
+ "Mark NODE as invisible."
+ (set! (visible? node) #f))
;;;