ShinyCocos
카테고리 없음 2011. 2. 5. 23:48
Cocos2D 루비 wrapper로 Cocos2d Document에 있는 Hello Action을 작성해본 코드
괜히 루비로 했나.ㅠ
자료가 별로 없네.ㅠ reverse왜 안먹는지 알수가 없군....
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | class MyLayer < Cocos2D::Layer class MyLayer < Cocos2D::Layer include Cocos2D def initialize @label = Label. new ( "Hello World" , "Marker Felt" , 64 ) win_size = Cocos2D::Director.win_size @label .position = [win_size[ 0 ]/ 2 ,win_size[ 1 ]/ 2 ] add_child @label action = Cocos2D::Actions::ScaleBy. new ( 3 . 0 , 2 . 5 , 2 . 5 ) @label .run_action(action) @sprite = Cocos2D::Sprite. new ( "grossini.png" ) @sprite .position = [ 0 , 50 ] add_child ( @sprite , :z => 1 ) rotateAction = Cocos2D::Actions::RotateBy. new ( 4 . 0 , 180 * 4 ) jumpAction = Cocos2D::Actions::JumpBy. new ( 4 ,[win_size[ 0 ], 0 ], 100 , 4 ) forward = Cocos2D::Actions::Spawn. new (rotateAction,jumpAction); backward = forward.reverse if backward == nil rotateAction2 = Cocos2D::Actions::RotateBy. new ( 4 . 0 ,- 180 * 4 ) jumpAction2 = Cocos2D::Actions::JumpBy. new ( 4 ,[-win_size[ 0 ], 0 ], 100 , 4 ) backward = Cocos2D::Actions::Spawn. new (rotateAction2,jumpAction2); end sequence = Cocos2D::Actions::Sequence. new (backward,forward); repeat = Cocos2D::Actions::Repeat. new (sequence, 2 ) @sprite .run_action repeat end end if $0 == "ShinyCocos" Cocos2D::Director.set_orientation Cocos2D::Director:: ORIENTATION_LANDSCAPE_RIGHT scene = Cocos2D::Scene. new layer = MyLayer. new scene.add_child(layer) Cocos2D::Director.run_scene scene else $stderr .puts "This script should be run only from a ShinyCocos environment" end |