Skip to content

Instantly share code, notes, and snippets.

@diclophis
Created February 23, 2010 02:25
Show Gist options
  • Save diclophis/311777 to your computer and use it in GitHub Desktop.
Save diclophis/311777 to your computer and use it in GitHub Desktop.
# GravitronShiftr
#
# just a simple test of ShinyCocos2d
class DemoScene < Cocos2D::Scene
include Cocos2D
def initialize
@layer = Layer.new
@map = TMXTiledMap.new("sewers.tmx")
@layer.add_child(@map)
@sprites = []
add_child @layer
schedule(:update)
Cocos2D::Director.add_touch_handler(self)
end
def update(dt)
dx = (dt * -50.0)
x, y = @layer.position
nx = x + dx
@layer.position = [nx, y]
dx = nil
dt = nil
x = nil
y = nil
nx = nil
end
def touches_moved(touches)
end
def touches_ended(touches)
touch_location = touches.first[:location]
sprite = Sprite.new("grossini.png")
new_position = Director.convert_to_gl(touch_location)
sprite.position = new_position
add_child sprite
@sprites << sprite
new_position = nil
sprite = nil
touch_location = nil
end
end
Cocos2D::Director.set_2d_projection
Cocos2D::Director.set_orientation Cocos2D::Director::ORIENTATION_LANDSCAPE_RIGHT
Cocos2D::Director.set_animation_interval 1.0/60.0
Cocos2D::Director.display_fps true
Cocos2D::Director.run_scene DemoScene.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment