From f3250f59432305d72129f36705505a42f6abe7b0 Mon Sep 17 00:00:00 2001 From: neochuky Date: Thu, 2 Aug 2012 12:03:36 +0200 Subject: [PATCH] Callback moved to touchclass --- assets/demo-scripts/demo-opengl.rb | 35 ++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/assets/demo-scripts/demo-opengl.rb b/assets/demo-scripts/demo-opengl.rb index 1a80aa4..1d0b0f1 100644 --- a/assets/demo-scripts/demo-opengl.rb +++ b/assets/demo-scripts/demo-opengl.rb @@ -153,20 +153,41 @@ def changeAngle ####################################################### # -# Activity +# TouchGLSurfaceView # -# Start a new activity or connect to $activity +# A surface view that reacts to touch events # ruboto_generate(android.opengl.GLSurfaceView => "TouchSurfaceView") class TouchSurfaceView + + def initialize(context) + super context + + self.initialize_ruboto_callbacks do + def on_touch_event(event) + if event.getAction == MotionEvent::ACTION_DOWN + @renderer.changeAngle + request_render + end + return true + end + end + end + def renderer= renderer @renderer = renderer super renderer end end +####################################################### +# +# Activity +# +# Start a new activity or connect to $activity +# $activity.start_ruboto_activity "$glsurface" do setTitle "GLSurfaceView" @@ -174,16 +195,6 @@ def on_create(bundle) @surface_view = TouchSurfaceView.new(self) @surface_view.renderer = RubotoGLSurfaceViewRenderer.new self.content_view = @surface_view - - @surface_view.initialize_ruboto_callbacks do - def on_touch_event(event) - if event.getAction == MotionEvent::ACTION_DOWN - @renderer.changeAngle - request_render - end - return true - end - end end def on_resume