Sha256: 83a35096fe0745efc58e311d314ef0adec3a7393fa708f7e935f70485b28586f
Contents?: true
Size: 869 Bytes
Versions: 8
Compression:
Stored size: 869 Bytes
Contents
define_behavior :score_keeper do requires :backstage, :stage setup do clear if score.nil? # TODO helper for "attached subactor" label = stage.create_actor(:label, actor.attributes) actor.has_attributes label: label actor.when :position_changed do actor.label.x = actor.x actor.label.y = actor.y end actor.when :remove_me do label.remove end update_text reacts_with :subtract, :add end helpers do def score backstage[:score] end def clear backstage[:score] = 0 end def add(amount) backstage[:score] += amount update_text end def subtract(amount) backstage[:score] -= amount update_text end def update_text actor.label.text = score end end end define_actor :score do has_behavior :score_keeper, layered: 999 end
Version data entries
8 entries across 8 versions & 1 rubygems