Skip to content

Instantly share code, notes, and snippets.

@diclophis
Created February 22, 2010 09:50
Show Gist options
  • Save diclophis/310974 to your computer and use it in GitHub Desktop.
Save diclophis/310974 to your computer and use it in GitHub Desktop.
# GravitronShiftr
#
# just a simple test of ShinyCocos2d
# i could get used to this
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
@layer.position = [x + dx, y]
end
def touches_moved(touches)
end
def touches_ended(touches)
sprite = Sprite.new("grossini.png")
sprite.position = Director.convert_to_gl(touches.first[:location])
add_child sprite
@sprites << sprite
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