X-Git-Url: http://nitlanguage.org diff --git a/lib/gamnit/flat.nit b/lib/gamnit/flat.nit index 6471c8f..f6e0fd2 100644 --- a/lib/gamnit/flat.nit +++ b/lib/gamnit/flat.nit @@ -29,7 +29,8 @@ # and the like. It can be used to standardize the size of the UI across # devices. It is used to position the sprites in `App::ui_sprites`. # -# See the sample game at `contrib/asteronits/`. +# See the sample game at `contrib/asteronits/` and the basic project template +# at `lib/gamnit/examples/template_flat/`. module flat import glesv2 @@ -40,6 +41,7 @@ import performance_analysis import gamnit import gamnit::cameras +import gamnit::dynamic_resolution import gamnit::limit_fps import android_two_fingers_motion is conditional(android) @@ -110,6 +112,36 @@ class Sprite scale_direct = value end + # Red tint applied to `texture` on draw + fun red: Float do return tint[0] + + # Red tint applied to `texture` on draw + fun red=(value: Float) + do + if isset _tint and value != red then needs_update + tint[0] = value + end + + # Green tint applied to `texture` on draw + fun green: Float do return tint[1] + + # Green tint applied to `texture` on draw + fun green=(value: Float) + do + if isset _tint and value != green then needs_update + tint[1] = value + end + + # Blue tint applied to `texture` on draw + fun blue: Float do return tint[2] + + # Blue tint applied to `texture` on draw + fun blue=(value: Float) + do + if isset _tint and value != blue then needs_update + tint[2] = value + end + # Transparency applied to `texture` on draw fun alpha: Float do return tint[3] @@ -324,13 +356,16 @@ redef class App # Draw the whole screen, all `glDraw...` calls should be executed here protected fun frame_core_draw(display: GamnitDisplay) do - perf_clock_main.lapse + frame_core_dynamic_resolution_before display + perf_clock_main.lapse frame_core_world_sprites display perfs["gamnit flat world_sprites"].add perf_clock_main.lapse frame_core_ui_sprites display perfs["gamnit flat ui_sprites"].add perf_clock_main.lapse + + frame_core_dynamic_resolution_after display end private fun frame_core_sprites(display: GamnitDisplay, sprite_set: SpriteSet, camera: Camera) @@ -623,6 +658,7 @@ private class SpriteSet redef fun add(e) do + if contexts_items.has(e.context) then return map_sprite e super end @@ -633,6 +669,12 @@ private class SpriteSet if e isa Sprite then unmap_sprite e end + redef fun remove_all(e) + do + if not has(e) then return + remove e + end + redef fun clear do super