lib/cyberarm_engine/engine.rb in cyberarm_engine-0.10.2 vs lib/cyberarm_engine/engine.rb in cyberarm_engine-0.11.0
- old
+ new
@@ -56,15 +56,19 @@
super
current_state.button_up(id) if current_state
end
def push_state(klass, options={})
+ options = {setup: true}.merge(options)
+
if klass.instance_of?(klass.class) && defined?(klass.options)
@states << klass
+ klass.setup if options[:setup]
else
@states << klass.new(options) if child_of?(klass, GameState)
@states << klass.new if child_of?(klass, Element::Container)
+ current_state.setup if current_state.class == klass && options[:setup]
end
end
private def child_of?(input, klass)
input.ancestors.detect {|c| c == klass}
@@ -92,6 +96,6 @@
a2 = a1 + step
draw_line(cx + Gosu.offset_x(a1, r), cy + Gosu.offset_y(a1, r), color, cx + Gosu.offset_x(a2, r), cy + Gosu.offset_y(a2, r), color, z)
end
end
end
-end
\ No newline at end of file
+end