Changeset 27670
- Timestamp:
- 12/31/08 15:09:24 (4 years ago)
- Location:
- lang/ruby/starframe
- Files:
-
- 2 modified
-
lib/starframe/sprite/collection.rb (modified) (5 diffs)
-
test/starframe/sprite/test_collection.rb (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/starframe/lib/starframe/sprite/collection.rb
r27524 r27670 55 55 @sprites << sprite 56 56 sprite.instance_variable_set :@collection, self 57 self 57 58 end 58 59 alias << add … … 62 63 @sprites.delete sprite 63 64 sprite.instance_variable_set :@collection, nil 65 self 64 66 end 65 67 … … 67 69 def each &block 68 70 @sprites.each &block 71 self 69 72 end 70 73 … … 77 80 def update 78 81 @sprites.each &:call_update 82 self 79 83 end 80 84 # 所属している全てのスプライトの更新時イベントをコールする。 81 85 def render 82 86 @sprites.each &:call_render 87 self 83 88 end 84 89 … … 86 91 def render_to texture 87 92 @sprites.each{ |sprite| sprite.render_to texture } 93 self 88 94 end 89 95 end -
lang/ruby/starframe/test/starframe/sprite/test_collection.rb
r27516 r27670 36 36 assert_equal @collection, @sprite.collection 37 37 end 38 def test_collection_add_should_return_self 39 assert_equal @collection, @collection.add(@sprite) 40 end 38 41 def test_collection_add_do_not_duplication 39 42 @collection.add @sprite 43 @collection.add @sprite 44 assert_equal 1, @collection.size 45 assert_equal @collection, @sprite.collection 46 end 47 def test_collection_add 40 48 @collection.add @sprite 41 49 assert_equal 1, @collection.size … … 54 62 assert_nil @sprite.collection 55 63 end 64 def test_collection_delete_should_return_self 65 @collection.add @sprite 66 assert_equal @collection, @collection.delete(@sprite) 67 end 56 68 57 69 def test_collection_each … … 62 74 end 63 75 assert_equal [@sprite], @sprites 76 end 77 def test_collection_each_should_return_self 78 assert_equal @collection, @collection.each{} 64 79 end 65 80 … … 88 103 end 89 104 105 def test_collection_update_should_return_self 106 assert_equal @collection, @collection.update 107 end 108 def test_collection_render_should_return_self 109 assert_equal @collection, @collection.render 110 end 111 90 112 def test_collection_render_to 91 113 @collection.add @sprite … … 95 117 96 118 assert_equal [:render_to, texture], @sprite.called_methods.last 119 end 120 def test_collection_render_to_should_return_self 121 assert_equal @collection, @collection.render_to(nil) 97 122 end 98 123
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)