contrib & examples: update users of mnit implementations
[nit.git] / contrib / friendz / src / friendz_android.nit
index 94b9d2b..4f40ca7 100644 (file)
 module friendz_android
 
 import friendz
-import mnit_android
+import mnit::android
+import android::landscape
 
 redef class App
-       redef fun window_created
+       # Zoom applied for the device display from the game logic coordinates
+       var zoom = 1.0
+
+       redef fun on_create
        do
                super
-               var w = screen_width
-               display.set_viewport(0,0,w,w*display.height/display.width)
+               var h = screen_height
+               display.set_viewport(0,0,h*display.width/display.height,h)
+
+               zoom = display.height.to_f / h.to_f
+               default_mediaplayer.looping = true
+       end
+
+       redef fun input(input_event)
+       do
+               if input_event isa KeyEvent then
+                       return false
+               else
+                       return super
+               end
        end
 end
 
 redef class AndroidPointerEvent
-       redef fun is_motion do return not motion_event.just_went_down
+       redef fun is_motion do return is_move
+
+       redef fun x do return super / app.zoom
+       redef fun y do return super / app.zoom
 end