lib/android: revamp entrypoint
[nit.git] / lib / android / game.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # Android services and implementation of app.nit for gamnit and mnit
16 module game
17
18 import platform
19 import native_app_glue
20 import dalvik
21 private import log
22 private import assets
23
24 redef class App
25 redef fun init_window
26 do
27 super
28 on_create
29 on_restore_state
30 on_start
31 end
32
33 redef fun term_window
34 do
35 super
36 on_stop
37 end
38
39 # Is the application currently paused?
40 var paused = true
41
42 redef fun pause
43 do
44 paused = true
45 on_pause
46 super
47 end
48
49 redef fun resume
50 do
51 paused = false
52 on_resume
53 super
54 end
55
56 redef fun save_state do on_save_state
57
58 redef fun lost_focus
59 do
60 paused = true
61 super
62 end
63
64 redef fun gained_focus
65 do
66 paused = false
67 super
68 end
69
70 redef fun destroy do on_destroy
71 end