M example.lisp => example.lisp +2 -1
@@ 31,7 31,8 @@
(setf (fairy:width *rec*) 200)
(sleep 0.5)
-(setf (fairy:origin *rec*) (gamekit:vec2 230 20))
+(setf (fairy:origin (fairy:get-child *root* :rectangle))
+ (gamekit:vec2 230 20))
(sleep 0.5)
(setf (fairy:visible *rec*) nil)
M fairy.lisp => fairy.lisp +7 -0
@@ 11,6 11,7 @@
layer
boundary
add-child
+ get-child
delete-child
delete-child-with-key))
@@ 77,6 78,12 @@
(defmethod add-child ((el layer) child &key with-key)
(setf (children el) (cons (cons with-key child) (children el))))
+(defmethod get-child ((el layer) key)
+ (cdr (assoc key (children el))))
+
+(defmethod (setf get-child) (value (el layer) key)
+ (setf (cdr (assoc key (children el))) value))
+
(defmethod delete-child ((el layer) child)
(setf (children el) (remove child (children el) :key #'cdr)))