Changeset 27506
- Timestamp:
- 12/28/08 11:48:10 (4 years ago)
- Location:
- lang/ruby/starframe
- Files:
-
- 7 modified
-
lib/starframe/eventable.rb (modified) (3 diffs)
-
lib/starframe/sprite.rb (modified) (6 diffs)
-
lib/starframe/sprite/animatable.rb (modified) (6 diffs)
-
lib/starframe/sprite/animation.rb (modified) (4 diffs)
-
lib/starframe/sprite/collidable.rb (modified) (1 diff)
-
lib/starframe/sprite/patternable.rb (modified) (2 diffs)
-
mkrdoc.bat (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/starframe/lib/starframe/eventable.rb
r27475 r27506 2 2 3 3 module StarFrame 4 # = Eventableモジュール5 4 # イベント駆動を実装するモジュール。 6 5 # … … 8 7 # 9 8 # また、メソッドチェインを利用して各イベントの前後に他の処理を割り込ませることができる。 9 # 10 # 独自クラスにこのモジュールをincludeすることで、Sprite::Animatable等のモジュールを使用することができるようになる。 10 11 module Eventable 12 #:stopdoc: 13 def self.included klass 14 klass.extend ClassMethods 15 end 16 #:startdoc: 17 11 18 # 初期化時イベントをコールする。 12 19 def call_init *args … … 40 47 41 48 private 42 # 初期化時にコールされるイベント。 49 # 初期化時に呼ばれます。 50 # 引数にはnewに渡された全ての引数が渡されます。 43 51 def init *args 44 #:doc:45 52 end 46 # 終了時にコールされるイベント。53 # 消滅したときに呼ばれます。 47 54 def quit 48 #:doc:49 55 end 50 # 更新時に コールされるイベント。56 # 更新時に呼ばれます。 51 57 def update 52 #:doc:53 58 end 54 # 描画時に コールされるイベント。59 # 描画時に呼ばれます。 55 60 def render 56 #:doc:57 end58 59 def self.included klass #:nodoc:60 klass.extend ClassMethods61 61 end 62 62 -
lang/ruby/starframe/lib/starframe/sprite.rb
r27483 r27506 11 11 12 12 module ClassMethods 13 #:stopdoc: 13 14 private 14 15 # オプション用アクセサ定義メソッド 15 def attr_option_accessor *keys #:nodoc:16 def attr_option_accessor *keys 16 17 keys.each do |key| 17 18 define_option_writer key, key … … 21 22 22 23 # オプション一括変更用アクセサ定義メソッド 23 def attr_option_slimer_writer name, keys #:nodoc:24 def attr_option_slimer_writer name, keys 24 25 define_option_writer name, *keys 25 26 end 26 27 27 def define_option_writer name, *keys #:nodoc:28 def define_option_writer name, *keys 28 29 default = OPTIONS_DEFAULT[keys.first] 29 30 … … 48 49 END 49 50 end 51 #:startdoc: 50 52 end 51 53 end … … 290 292 end 291 293 292 def call_update #:nodoc:294 def call_update #:nodoc: 293 295 move 294 296 update … … 296 298 297 299 private 298 def initialize_texture 300 def initialize_texture #:nodoc: 299 301 @texture ||= self.class.texture 300 302 @center_x, @center_y = self.class.center_x, self.class.center_y … … 311 313 end 312 314 313 # render_toメソッドの最適化 314 def redifine_render_to #:doc: 315 # render_toメソッドを最適化する 316 # 317 # 通常はinitialize内で自動的に実行されるため、ユーザが実行する必要はない。 318 def redifine_render_to 315 319 instance_eval <<-END 316 320 def render_to other -
lang/ruby/starframe/lib/starframe/sprite/animatable.rb
r27493 r27506 19 19 # end 20 20 module Animatable 21 def self.included sprite #:nodoc: 21 #:stopdoc: 22 def self.included sprite 22 23 unless sprite.include? StarFrame::Eventable 23 24 raise TypeError, "StarFrame::Sprite::Animatable : has need \"include StarFrame::Eventable\"", caller … … 26 27 end 27 28 28 def call_init_with_animation *args #:nodoc:29 def call_init_with_animation *args 29 30 @animations = {} 30 31 self.class.animations.each do |name, animation_class| … … 34 35 end 35 36 36 def call_update_with_animation #:nodoc:37 def call_update_with_animation 37 38 call_update_without_animation 38 39 … … 41 42 end 42 43 end 44 #:startdoc: 43 45 44 46 # アニメーションを取得 … … 48 50 49 51 module ClassMethods 50 attr_accessor :animations #:nodoc: 52 #:stopdoc: 53 attr_reader :animations 51 54 52 def self.extended sprite #:nodoc: 55 private 56 def self.extended sprite 53 57 sprite.instance_variable_set :@animations, {} 54 58 sprite.alias_method_chain :call_init, :animation … … 56 60 end 57 61 58 def inherited klass #:nodoc:62 def inherited klass 59 63 klass.instance_variable_set :@animations, @animations.dup 60 64 super 61 65 end 66 #:startdoc: 62 67 68 private 63 69 # アニメーションを定義 64 70 # -
lang/ruby/starframe/lib/starframe/sprite/animation.rb
r27505 r27506 9 9 # 初期化 10 10 def initialize sprite 11 # @max_frameが0の時に例外出したい12 11 @sprite = sprite 13 12 @animations = self.class.animations 13 14 # @max_frameが0の時に例外出したい 14 15 @max_frame = self.class.max_frame 15 16 @frame = 0 16 17 17 options = self.class. instance_variable_get(:@options)18 options = self.class.options 18 19 @loop = (options[:loop].nil? ? true : options[:loop]) 19 20 @running = (options[:start].nil? ? true : options[:start]) … … 62 63 63 64 module ClassMethods 65 #:stopdoc: 66 attr_reader :animations, :max_frame, :options 64 67 @@method_count = 0 65 attr_reader :animations, :max_frame 66 67 def self.extended sprite #:nodoc: 68 69 private 70 def self.extended sprite 71 sprite.instance_variable_set :@animations, Hash.new{ |hash, key| hash[key] = [] } 68 72 sprite.instance_variable_set :@max_frame, 0 69 sprite.instance_variable_set :@animations, Hash.new{ |hash, key| hash[key] = [] }70 73 sprite.instance_variable_set :@options, {} 71 74 end 72 75 73 def inherited klass #:nodoc: 76 def inherited klass 77 klass.instance_variable_set :@animations, @animations.dup 74 78 klass.instance_variable_set :@max_frame, @max_frame 75 klass.instance_variable_set :@animations, @animations.dup76 79 klass.instance_variable_set :@options, @options 77 80 super 78 81 end 79 80 protected 82 #:startdoc: 83 84 private 81 85 # タイムラインを直列モードに変更するブロック。 82 86 # … … 100 104 101 105 # タイムラインのモードを変更するブロック。 106 # 107 # serialメソッドとparallelメソッドの共通ロジック。 108 # 通常は使用する必要はない。 102 109 def timeline parallel = false, &block 103 110 last_parallel = @parallel … … 108 115 @parallel = last_parallel 109 116 end 110 private :timeline111 117 112 118 # アニメーションを追加する。 -
lang/ruby/starframe/lib/starframe/sprite/collidable.rb
r27489 r27506 53 53 54 54 module ClassMethods 55 attr_accessor :collisions #:nodoc: 55 #:stopdoc: 56 attr_reader :collisions 56 57 57 def self.extended sprite #:nodoc: 58 private 59 def self.extended sprite 58 60 sprite.instance_variable_set :@collisions, {} 59 61 sprite.alias_method_chain :call_init, :collision 60 62 end 61 63 62 def inherited klass #:nodoc:64 def inherited klass 63 65 klass.instance_variable_set :@collisions, @collisions.dup 64 66 super 65 67 end 68 #:startdoc: 66 69 70 private 67 71 # 当たり判定を定義 68 72 # -
lang/ruby/starframe/lib/starframe/sprite/patternable.rb
r27423 r27506 20 20 # 現在のパターン番号 21 21 attr_reader :pattern_index 22 # パターン番号を 設定する22 # パターン番号を変更する 23 23 def pattern_index= index 24 24 @pattern_index = index … … 26 26 end 27 27 28 module ClassMethods #:nodoc: 29 attr_reader :patterns #:nodoc: 28 #:stopdoc: 29 module ClassMethods 30 attr_reader :patterns 30 31 31 def self.extended sprite #:nodoc: 32 private 33 def self.extended sprite 32 34 sprite.instance_variable_set :@patterns, [] 33 35 sprite.alias_method_chain :initialize, :pattern 34 36 end 35 37 36 def inherited klass #:nodoc:38 def inherited klass 37 39 klass.instance_variable_set :@patterns, @patterns.dup 38 40 super 39 41 end 40 42 end 43 #:startdoc: 41 44 end 42 45 end -
lang/ruby/starframe/mkrdoc.bat
r27496 r27506 1 rdoc lib -U --op doc --charset UTF-8 --inline-source --title "StarFrame RDoc Documentation" --main StarFrame --accessor attr_option_accessor=rw --accessor attr_option_slimer_writer=w 1 rdoc lib -U --op doc --charset UTF-8 --inline-source --title "StarFrame RDoc Documentation" --main StarFrame --accessor attr_option_accessor=rw --accessor attr_option_slimer_writer=w --all
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)