Skip to content

Commit

Permalink
Callback moved to touchclass
Browse files Browse the repository at this point in the history
  • Loading branch information
neochuky committed Aug 2, 2012
1 parent de02f18 commit f3250f5
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions assets/demo-scripts/demo-opengl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,37 +153,48 @@ 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"

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
Expand Down

0 comments on commit f3250f5

Please sign in to comment.