Permalink
Browse files

added sample 13a with nifty. working on screen controllers

  • Loading branch information...
1 parent 1e83e0f commit 538bc32b9fad59151b88d80bbcbc403b0a9b0c82 @jwoertink committed Oct 25, 2011
Showing with 18 additions and 30 deletions.
  1. +1 −1 lib/maze.rb
  2. +17 −29 lib/samples/sample13.rb
View
2 lib/maze.rb
@@ -277,7 +277,7 @@ def simpleUpdate(tpf)
# finish_time != (@counter / 1000)
# @targets.size == actual targets shot * 2 ....
@time_text.text = "FINISH TIME: #{finish_time.ceil} seconds. You shot #{@targets.size}/#{@targets_generated} targets"
- self.paused = true #This might lock up the game..
+ self.paused = true
input_manager.cursor_visible = true
flyCam.enabled = false
# use nifty
View
46 lib/samples/sample13.rb
@@ -1,47 +1,35 @@
=begin
- Sample using NiftyGui
+ Sample using NiftyGui with XML
=end
java_import "com.jme3.app.SimpleApplication"
-java_import "com.jme3.math.ColorRGBA"
java_import "com.jme3.niftygui.NiftyJmeDisplay"
java_import "de.lessvoid.nifty.Nifty"
-java_import "de.lessvoid.nifty.builder.ScreenBuilder"
-java_import "de.lessvoid.nifty.builder.LayerBuilder"
-java_import "de.lessvoid.nifty.builder.PanelBuilder"
-java_import "de.lessvoid.nifty.controls.button.builder.ButtonBuilder"
-java_import "de.lessvoid.nifty.screen.DefaultScreenController"
+java_import "de.lessvoid.nifty.screen.Screen"
+java_import "de.lessvoid.nifty.screen.ScreenController"
class Sample13 < SimpleApplication
field_accessor :flyCam
+ def initialize
+ @game_state = 0
+ end
+
def simpleInitApp
- view_port.background_color = ColorRGBA.new(0.7, 0.8, 1.0, 1.0)
+ if @game_state.zero?
+ load_start_screen
+ end
+
+ end
+
+ def load_start_screen
nifty_display = NiftyJmeDisplay.new(asset_manager, input_manager, audio_renderer, gui_view_port)
nifty = nifty_display.nifty
+ nifty.from_xml(File.join("assets", "Interface", "screen.xml"), "start")
+
gui_view_port.add_processor(nifty_display)
+ #flyCam.enabled = false
flyCam.drag_to_rotate = true
- nifty.load_style_file("nifty-default-styles.xml")
- nifty.load_control_file("nifty-default-controls.xml")
-
-
-
- nifty.addScreen("Screen_ID", ScreenBuilder.new("Hello Nifty Screen") {
- controller(DefaultScreenController.new)
- layer(LayerBuilder.new("Layer_ID") {
- childLayoutVertical
- panel(PanelBuilder.new("Panel_ID") {
- childLayoutCenter
- control(ButtonBuilder.new("Button_ID", "Hello Nifty") {
- alignCenter
- valignCenter
- height("5%")
- width("15%")
- })
- })
- })
- }.build(nifty))
- nifty.goto_screen("Screen_ID")
end
end

0 comments on commit 538bc32

Please sign in to comment.