diff --git a/Gemfile b/Gemfile index fcaada2..7689cfe 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,8 @@ source :rubygems gem 'motion-cocoapods' -gem 'bubble-wrap' \ No newline at end of file +gem 'bubble-wrap', :require => 'bubble-wrap/core' + +group :development do + gem 'pry' +end \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 99fcc9a..8ecc1dc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,6 +16,7 @@ GEM open4 (~> 1.3.0) rake (~> 0.9.0) xcodeproj (>= 0.3.0) + coderay (1.0.7) colored (1.2) escape (0.0.4) faraday (0.8.4) @@ -25,6 +26,7 @@ GEM hashie (1.2.0) i18n (0.6.0) json (1.7.4) + method_source (0.7.1) motion-cocoapods (1.1.0) cocoapods (>= 0.9.1) multi_json (1.3.6) @@ -36,7 +38,12 @@ GEM hashie (~> 1.2) multi_json (~> 1.3) open4 (1.3.0) + pry (0.9.9.6) + coderay (~> 1.0.5) + method_source (~> 0.7.1) + slop (>= 2.4.4, < 3) rake (0.9.2.2) + slop (2.4.4) xcodeproj (0.3.1) activesupport (~> 3.2.6) @@ -46,3 +53,4 @@ PLATFORMS DEPENDENCIES bubble-wrap motion-cocoapods + pry diff --git a/Rakefile b/Rakefile index d30a202..164311a 100644 --- a/Rakefile +++ b/Rakefile @@ -5,7 +5,6 @@ require 'rubygems' require 'bundler' Bundler.require :default - Motion::Project::App.setup do |app| app.name = 'blocks' app.files_dependencies "app/app_delegate.rb" => ["app/commons/cocos2d_app_delegate.rb", "app/commons/touch_sprite.rb"] @@ -14,14 +13,14 @@ Motion::Project::App.setup do |app| pod do |s| s.name = 'cocos2d' s.license = 'MIT' - s.version = '2.0.0' + s.version = '2.1.0.pre' s.summary = 'cocos2d for iPhone is a framework for building 2D games, demos, and other graphical/interactive applications for iPod Touch, iPhone, iPad and Mac. It is based on the cocos2d design but instead of using python it, uses objective-c.' s.homepage = 'http://www.cocos2d-iphone.org' s.author = { 'Ricardo Quesada' => 'ricardoquesada@gmail.com', 'Zynga Inc.' => 'https://zynga.com/' } - s.source = {:git => 'https://github.com/cocos2d/cocos2d-iphone.git', :tag => 'release-2.0'} + s.source = {:git => 'https://github.com/cocos2d/cocos2d-iphone.git', :commit => '04d1ad21487de8624243f7905d113c6715537d21'} s.source_files = ['cocos2d/**/*.{h,m,c}', 'external/kazmath/src/**/*.{c,h}', 'external/kazmath/include/**/*.{c,h}'] + FileList['external/libpng/*.{h,c}'].exclude(/pngtest/) s.xcconfig = { diff --git a/vendor/Pods/BuildHeaders/cocos2d/CCDrawNode.h b/vendor/Pods/BuildHeaders/cocos2d/CCDrawNode.h new file mode 120000 index 0000000..a8b2b49 --- /dev/null +++ b/vendor/Pods/BuildHeaders/cocos2d/CCDrawNode.h @@ -0,0 +1 @@ +../../cocos2d/cocos2d/CCDrawNode.h \ No newline at end of file diff --git a/vendor/Pods/BuildHeaders/cocos2d/ccShader_PositionColorLengthTexture_frag.h b/vendor/Pods/BuildHeaders/cocos2d/ccShader_PositionColorLengthTexture_frag.h new file mode 120000 index 0000000..35222dc --- /dev/null +++ b/vendor/Pods/BuildHeaders/cocos2d/ccShader_PositionColorLengthTexture_frag.h @@ -0,0 +1 @@ +../../cocos2d/cocos2d/ccShader_PositionColorLengthTexture_frag.h \ No newline at end of file diff --git a/vendor/Pods/BuildHeaders/cocos2d/ccShader_PositionColorLengthTexture_vert.h b/vendor/Pods/BuildHeaders/cocos2d/ccShader_PositionColorLengthTexture_vert.h new file mode 120000 index 0000000..652e2a6 --- /dev/null +++ b/vendor/Pods/BuildHeaders/cocos2d/ccShader_PositionColorLengthTexture_vert.h @@ -0,0 +1 @@ +../../cocos2d/cocos2d/ccShader_PositionColorLengthTexture_vert.h \ No newline at end of file diff --git a/vendor/Pods/Headers/cocos2d/CCDrawNode.h b/vendor/Pods/Headers/cocos2d/CCDrawNode.h new file mode 120000 index 0000000..a8b2b49 --- /dev/null +++ b/vendor/Pods/Headers/cocos2d/CCDrawNode.h @@ -0,0 +1 @@ +../../cocos2d/cocos2d/CCDrawNode.h \ No newline at end of file diff --git a/vendor/Pods/Headers/cocos2d/ccShader_PositionColorLengthTexture_frag.h b/vendor/Pods/Headers/cocos2d/ccShader_PositionColorLengthTexture_frag.h new file mode 120000 index 0000000..35222dc --- /dev/null +++ b/vendor/Pods/Headers/cocos2d/ccShader_PositionColorLengthTexture_frag.h @@ -0,0 +1 @@ +../../cocos2d/cocos2d/ccShader_PositionColorLengthTexture_frag.h \ No newline at end of file diff --git a/vendor/Pods/Headers/cocos2d/ccShader_PositionColorLengthTexture_vert.h b/vendor/Pods/Headers/cocos2d/ccShader_PositionColorLengthTexture_vert.h new file mode 120000 index 0000000..652e2a6 --- /dev/null +++ b/vendor/Pods/Headers/cocos2d/ccShader_PositionColorLengthTexture_vert.h @@ -0,0 +1 @@ +../../cocos2d/cocos2d/ccShader_PositionColorLengthTexture_vert.h \ No newline at end of file diff --git a/vendor/Pods/Pods.bridgesupport b/vendor/Pods/Pods.bridgesupport index 4fb04ff..abf74d3 100644 --- a/vendor/Pods/Pods.bridgesupport +++ b/vendor/Pods/Pods.bridgesupport @@ -1,351 +1,351 @@ - - + + - - - - - + + + + + - - - + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - + + + + + + - - - - + + + + - - - - - - + + + + + + - - - - + + + + - - - - + + + + - - + + - - - - + + + + - - - + + + - - - - + + + + - - - - + + + + - - - + + + - - - + + + - - - - + + + + - - - - + + + + - - + + - - - - + + + + - - - + + + - - - + + + - - - - + + + + - - - + + + - - - - + + + + - - - + + + - - - - + + + + - - - + + + - - - - + + + + - - + + - - - + + + - - + + - + - + - - - - + + + + - - - - + + + + - - + + - - + + - - - + + + - - - - + + + + - - - - + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + @@ -567,390 +567,390 @@ - + - + - + - - - - + + + + - - - - + + + + - - - - + + + + - - + + - + - - + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - + - - + + - - + + - - - + + + - - - + + + - - + + - - - + + + - + - + - - + + - - + + - - + + - + - - - + + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - - - + + + - + - + - - + + - - + + - - + + - - - - - - + + + + + + - - - + + + - - + + - - - - - + + + + + - - - - + + + + - - - - + + + + - - - - - + + + + + - - + + - + - - + + - - - + + + - - - - + + + + - - + + - - - + + + - - - + + + - + - + - - + + - + - + - + - + @@ -960,351 +960,351 @@ - + - + - - + + - - + + - - - + + + - - - - + + + + - - + + - + - + - - - - - - - - - + + + + + + + + + - - - - - + + + + + - - - - + + + + - - - - - + + + + + - - - + + + - - - - + + + + - - - - - + + + + + - - - + + + - - + + - - + + - - - - - + + + + + - - - + + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - - + + + - - - + + + - + - + - - - + + + - - - - + + + + - + - - + + - - - + + + - - - - - - + + + + + + - - - + + + - - - + + + - - + + - + - - + + - - - + + + - - + + - - - + + + - - - + + + - - - - + + + + - - - + + + - + - - - + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - + + - + - - + + - + - + - + @@ -1314,803 +1314,803 @@ - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - - + + + + - - + + - - - - + + + + - - - + + + - - - - + + + + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - - - + + + + + - - - - + + + + - - - - - - - - + + + + + + + + - - - - - - + + + + + + - - - - + + + + - - - - - + + + + + - - - + + + - - - - + + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - - - - + + + + + - - - - - + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - - - - + + + + + - - - - - + + + + + - - - + + + - - - - + + + + - - - + + + - - + + - - - + + + - - - + + + - - + + - + - - + + - + - + - + - - + + - - - + + + - - - + + + - - + + - - - + + + - - - - + + + + - - + + - - - - + + + + - - - + + + - - - - + + + + - - - + + + - + - - - - - + + + + + - - - - + + + + - - - - + + + + - - - - - - + + + + + + - + - - - + + + - - + + - - + + - - - + + + - + - + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - - + + + - - + + - - - - + + + + - - - + + + - - - + + + - + - + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - + - - - + + + - - + + - - + + - - + + - - - - - + + + + + - + - + - - - - + + + + - - + + - - - + + + - - - + + + - - - + + + - - - - - - + + + + + + - + - - + + - - + + - + - - + + - - + + - - - + + + - + - + - - + + - - + + - + - - - - + + + + - - + + - - + + - + - - + + - - + + - + @@ -2119,7 +2119,7 @@ - + @@ -2132,15 +2132,15 @@ - + - + - + @@ -2153,30 +2153,30 @@ - + - + - + - + - + @@ -2188,49 +2188,49 @@ - - - + + + - - + + - + - + - + - - + + - + - + - + @@ -2239,111 +2239,111 @@ - - - - + + + + - - - - + + + + - + - - + + - - - + + + - + - - + + - - - + + + - + - + - + - - + + - + - + - - + + - - - + + + - + - - + + - + - - + + @@ -2356,27 +2356,27 @@ - - - + + + - + - - + + - + - - + + @@ -2386,19 +2386,19 @@ - + - + - + - + @@ -2407,27 +2407,27 @@ - - + + - + - + - + - + @@ -2439,21 +2439,21 @@ - - - + + + - + - + - + @@ -2465,133 +2465,133 @@ - + - + - + - + - + - + - + - - + + - - + + - + - + - + - + - + - + - - + + - + - - - + + + - + - - + + - + - - + + - - - + + + - + - - - + + + @@ -2609,42 +2609,42 @@ - + - + - + - - + + - + - + - - - - + + + + @@ -2654,10 +2654,10 @@ - - - - + + + + @@ -2667,23 +2667,23 @@ - + - + - + - + - + @@ -2698,45 +2698,45 @@ - + - + - + - - + + - - + + - - + + - - + + - + @@ -2745,7 +2745,7 @@ - + @@ -2753,7 +2753,7 @@ - + @@ -2763,7 +2763,7 @@ - + @@ -2772,48 +2772,48 @@ - + - + - + - + - + - - + + - - + + - + @@ -2822,13 +2822,13 @@ - - - + + + - + @@ -2837,13 +2837,13 @@ - - - + + + - + @@ -2855,39 +2855,39 @@ - - - + + + - - - + + + - + - - - + + + - - - + + + @@ -2900,76 +2900,76 @@ - - - + + + - + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - + - - + + - - + + - - + + - - + + @@ -2978,7 +2978,7 @@ - + @@ -3011,20 +3011,20 @@ - - + + - - + + - + @@ -3039,11 +3039,11 @@ - + - + @@ -3059,7 +3059,7 @@ - + @@ -3099,22 +3099,22 @@ - + - + - + - + @@ -3133,62 +3133,62 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3215,7 +3215,7 @@ - + @@ -3236,57 +3236,57 @@ - + - - + + - - + + - + - - + + - - + + - + - - + + - - + + @@ -3301,37 +3301,37 @@ - + - + - - + + - - + + - + - + - + - + @@ -3341,11 +3341,11 @@ - + - + @@ -3355,39 +3355,39 @@ - + - + - + - + - + - + - + - + - + @@ -3402,84 +3402,84 @@ - + - + - + - + - + - + - + - + - - + + - + - - + + - + - - + + - - + + - - + + @@ -3492,58 +3492,58 @@ - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - - + + + + - - - - - + + + + + - - + + - - - + + + @@ -3561,33 +3561,33 @@ - + - + - + - - + + - - - - - - - + + + + + + + @@ -3600,11 +3600,11 @@ - + - + @@ -3620,79 +3620,79 @@ - + - - + + - - - + + + - - - - - - - + + + + + + + - + - + - + - + - - + + - + - + - - + + - + - - + + @@ -3702,12 +3702,12 @@ - - + + - + @@ -3716,7 +3716,7 @@ - + @@ -3735,23 +3735,23 @@ - + - - - + + + - + - - - + + + @@ -3764,31 +3764,31 @@ - + - + - + - + - + - + - + @@ -3803,26 +3803,26 @@ - - - - + + + + - - - - + + + + - - - - + + + + @@ -3832,46 +3832,46 @@ - - - - + + + + - + - + - - - - - + + + + + - - + + - - - - - + + + + + - - + + @@ -3889,43 +3889,43 @@ - - + + - - - - + + + + - - - - - + + + + + - - + + - - - - + + + + - - - - - + + + + + @@ -3935,23 +3935,23 @@ - + - + - + - + - + @@ -3969,145 +3969,145 @@ - - - - - + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - - + + + + + + + - - - + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - - + + + + + + + - - - + + + - + - + - + - + - + - + @@ -4125,11 +4125,11 @@ - + - + @@ -4138,46 +4138,46 @@ - + - + - - + + - + - - - + + + - + - - - + + + - + @@ -4192,49 +4192,49 @@ - - + + - - - + + + - - + + - - - + + + - + - + - + - + - + - + @@ -4249,36 +4249,36 @@ - - + + - - + + - + - + - - - - + + + + - - - - + + + + @@ -4288,20 +4288,20 @@ - + - + - - - - + + + + @@ -4311,18 +4311,18 @@ - - - - + + + + - + - + @@ -4331,32 +4331,32 @@ - + - - + + - - + + - - + + - - + + - + @@ -4366,31 +4366,31 @@ - + - - + + - + - - + + - + - + @@ -4402,15 +4402,15 @@ - + - - + + @@ -4420,15 +4420,15 @@ - + - - + + @@ -4438,19 +4438,19 @@ - + - + - - + + @@ -4459,107 +4459,107 @@ - - - - - - + + + + + + - - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - - - + + + + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - - - + + + + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - - - + + + + + + + @@ -4577,211 +4577,211 @@ - - + + - - - + + + - - + + - - - + + + - + - - + + - - - + + + - + - - + + - - - + + + - + - + - + - + - - - - + + + + - - - - - + + + + + - - - - + + + + - - - - - + + + + + - - + + - - - + + + - - - - + + + + - - - - - + + + + + - - - - + + + + - - + + - - - + + + - - - - + + + + - - - - - + + + + + - - - - + + + + - + - + - + @@ -4790,54 +4790,54 @@ - - + + - - - + + + - + - - + + - - - + + + - + - + - + - + @@ -4846,117 +4846,117 @@ - - - - + + + + - - - - - + + + + + - - - - + + + + - - - - - + + + + + - - + + - - - + + + - - - - + + + + - - - - - + + + + + - - - - + + + + - - + + - - - + + + - - - - + + + + - - - - - + + + + + - - - - + + + + @@ -4966,15 +4966,15 @@ - + - + - + @@ -4983,32 +4983,32 @@ - - + + - - - - + + + + - - + + - - - - + + + + @@ -5021,11 +5021,11 @@ - + - + @@ -5037,19 +5037,19 @@ - - - - - + + + + + - - - - - + + + + + @@ -5059,62 +5059,62 @@ - + - + - + - - - - - + + + + + - - - - - + + + + + - + - - + + - - + + - - + + - - + + @@ -5123,18 +5123,18 @@ - + - - + + - - - + + + @@ -5159,38 +5159,38 @@ - + - + - + - + - + - + - + - + @@ -5251,26 +5251,26 @@ - + - - + + - - + + - + - - + + @@ -5280,7 +5280,7 @@ - + @@ -5293,130 +5293,130 @@ - + - - + + - - - - + + + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -5432,11 +5432,11 @@ - + - + @@ -5452,7 +5452,7 @@ - + @@ -5485,106 +5485,106 @@ - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - + + + - - - - + + + + - + - - - + + + - + - - + + - + - - + + - + - - + + - - + + - - + + - - + + - + - + @@ -5656,15 +5656,15 @@ - + - + - + @@ -5680,7 +5680,7 @@ - + @@ -5708,175 +5708,175 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -5928,12 +5928,12 @@ - + - - + + @@ -5945,36 +5945,36 @@ - + - + - - + + - + - + - + - + @@ -5984,25 +5984,25 @@ - + - + - - + + - + - - + + @@ -6012,13 +6012,13 @@ - + - + @@ -6028,7 +6028,7 @@ - + @@ -6042,15 +6042,15 @@ - - - + + + - - - + + + @@ -6062,7 +6062,7 @@ - + @@ -6075,42 +6075,42 @@ - + - + - + - + - + - + - + - + - + @@ -6128,13 +6128,13 @@ - - + + - - + + @@ -6143,42 +6143,42 @@ - - - - + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - + + + + - + - + @@ -6191,59 +6191,59 @@ - - - + + + - - - - + + + + - - + + - - - + + + - - - - + + + + - + - - + + - + - - + + - + @@ -6252,68 +6252,68 @@ - - + + - - + + - + - + - + - + - + - + - + - + - - - - - - + + + + + + @@ -6323,126 +6323,126 @@ - - - - - - + + + + + + - + - + - + - - + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - + - + - + - + - + - - - - + + + + - - - - - - + + + + + + - - - + + + - + @@ -6455,62 +6455,62 @@ - + - + - - + + - + - + - - + + - + - - + + - + - - + + - - + + - + @@ -6522,124 +6522,124 @@ - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - + - - + + - + - - + + - - + + - - + + - + - + @@ -6648,25 +6648,25 @@ - - + + - - + + - - + + - - + + @@ -6699,49 +6699,49 @@ - - + + - - + + - + - - + + - + - + - + - - + + - - - + + + - + @@ -6754,98 +6754,98 @@ - + - + - + - + - + - + - - + + - + - + - + - + - + - - - + + + - + - - + + - - + + - + - - + + - + - + - + - - + + @@ -6863,41 +6863,41 @@ - - + + - - - + + + - + - - + + - + - - + + - + - - + + @@ -6910,49 +6910,49 @@ - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + @@ -6961,55 +6961,55 @@ - - + + - - - - - + + + + + - - + + - - - - - + + + + + - - + + - - - - - + + + + + - - + + - - - - - + + + + + @@ -7034,35 +7034,35 @@ - + - + - + - + - + - + - + - + @@ -7074,50 +7074,50 @@ - - + + - - + + - + - - + + - - + + - - + + - + - + - + @@ -7127,21 +7127,21 @@ - + - - - + + + - - - + + + @@ -7154,85 +7154,85 @@ - - - + + + - + - + - + - + - + - + - + - + - - + + - - - + + + - + - + - + - + - - + + @@ -7268,43 +7268,43 @@ - + - + - + - + - + - + - + - + - + - + @@ -7319,21 +7319,21 @@ - + - - + + - + - - + + @@ -7355,43 +7355,43 @@ - + - + - + - + - + - + - + - + - + - + @@ -7409,7 +7409,7 @@ - + @@ -7422,38 +7422,38 @@ - + - + - + - + - + - + - - + + - + @@ -7463,7 +7463,7 @@ - + @@ -7473,31 +7473,31 @@ - + - + - + - + - + - - + + @@ -7515,35 +7515,35 @@ - + - + - + - + - + - + - + - + @@ -7558,20 +7558,20 @@ - - + + - - + + - + @@ -7580,19 +7580,19 @@ - - - + + + - - - + + + - + @@ -7601,14 +7601,14 @@ - + - + @@ -7621,11 +7621,11 @@ - + - + @@ -7635,67 +7635,67 @@ - - + + - - - - - + + + + + - + - - - - - + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - - + + + + + + + - - - + + + - - + + @@ -7717,7 +7717,7 @@ - + @@ -7730,27 +7730,27 @@ - + - + - + - + - + - + @@ -7765,61 +7765,61 @@ - + - - + + - - + + - + - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - + + @@ -7829,74 +7829,74 @@ - + - - + + - + - + - + - - + + - - + + - - + + - - + + - + - - - + + + - - + + - + @@ -7909,11 +7909,11 @@ - + - + @@ -7923,7 +7923,7 @@ - + @@ -7938,11 +7938,11 @@ - + - + @@ -7952,18 +7952,18 @@ - + - + - + @@ -7972,144 +7972,144 @@ - - - - + + + + - - + + - + - - - - + + + + - + - - + + - + - + - - + + - + - - + + - - - - - + + + + + - + - - + + - - - + + + - + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - + + - - - + + + @@ -8119,16 +8119,16 @@ - + - + - - + + @@ -8143,48 +8143,48 @@ - - + + - - + + - + - + - + - - - + + + - - - + + + - + @@ -8198,19 +8198,19 @@ - + - - - + + + - - - + + + @@ -8222,27 +8222,27 @@ - - + + - - + + - - - + + + - - - + + + @@ -8261,25 +8261,25 @@ - - - + + + - - - + + + - - - - - + + + + + @@ -8289,37 +8289,37 @@ - - - - - + + + + + - + - + - + - - - - - - + + + + + + @@ -8329,29 +8329,29 @@ - - - - - - + + + + + + - + - + - - - - + + + + @@ -8361,27 +8361,27 @@ - - - - + + + + - + - + - - - - + + + + @@ -8391,31 +8391,31 @@ - - - - + + + + - + - + - - + + - + @@ -8433,30 +8433,30 @@ - + - - + + - + - + - + @@ -8472,12 +8472,12 @@ - - + + - + @@ -8487,17 +8487,17 @@ - - + + - + - - + + @@ -8521,8 +8521,8 @@ - - + + @@ -8531,16 +8531,16 @@ - - + + - + - + @@ -8549,28 +8549,28 @@ - - - + + + - + - + - + - + @@ -8594,7 +8594,7 @@ - + @@ -8613,19 +8613,19 @@ - + - + - + - + @@ -8643,7 +8643,7 @@ - + @@ -8653,33 +8653,33 @@ - - - - + + + + - + - + - + - + - + @@ -8691,31 +8691,31 @@ - + - + - + - + - + - - + + @@ -8731,20 +8731,20 @@ - - + + - - - - - + + + + + - + @@ -8754,43 +8754,43 @@ - - - - - - + + + + + + - + - + - + - - + + - - + + - - + + - + @@ -8803,15 +8803,15 @@ - + - + - + @@ -8823,9 +8823,9 @@ - - - + + + @@ -8844,23 +8844,23 @@ - + - + - + - + - + @@ -8869,7 +8869,7 @@ - + @@ -8881,51 +8881,51 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + @@ -8944,18 +8944,18 @@ - + - - - - - + + + + + @@ -8977,50 +8977,50 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -9033,23 +9033,23 @@ - - + + - - + + - - + + - - + + @@ -9058,25 +9058,25 @@ - + - + - + - + - - + + @@ -9097,31 +9097,31 @@ - + - - + + - + - - - - + + + + - + - + @@ -9131,29 +9131,29 @@ - + - + - + - + - + @@ -9165,13 +9165,13 @@ - + - + @@ -9192,11 +9192,11 @@ - - - - - + + + + + @@ -9206,17 +9206,17 @@ - + - + - + @@ -9234,65 +9234,65 @@ - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + @@ -9301,29 +9301,29 @@ - - + + - - + + - - + + - - + + - + @@ -9335,11 +9335,11 @@ - + - + @@ -9359,11 +9359,11 @@ - + - + diff --git a/vendor/Pods/Pods.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/vendor/Pods/Pods.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..d25c45c --- /dev/null +++ b/vendor/Pods/Pods.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/vendor/Pods/build-iPhoneSimulator/libPods.a b/vendor/Pods/build-iPhoneSimulator/libPods.a index e85e35d..aab28ea 100644 Binary files a/vendor/Pods/build-iPhoneSimulator/libPods.a and b/vendor/Pods/build-iPhoneSimulator/libPods.a differ diff --git a/vendor/Pods/cocos2d/cocos2d/CCActionCamera.h b/vendor/Pods/cocos2d/cocos2d/CCActionCamera.h index 3c3934c..4277678 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCActionCamera.h +++ b/vendor/Pods/cocos2d/cocos2d/CCActionCamera.h @@ -44,6 +44,8 @@ float upYOrig_; float upZOrig_; } +// XXX Needed for BridgeSupport +-(void) startWithTarget:(id)aTarget; @end /** CCOrbitCamera action diff --git a/vendor/Pods/cocos2d/cocos2d/CCActionCatmullRom.h b/vendor/Pods/cocos2d/cocos2d/CCActionCatmullRom.h index 1218913..b73ce58 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCActionCatmullRom.h +++ b/vendor/Pods/cocos2d/cocos2d/CCActionCatmullRom.h @@ -105,6 +105,8 @@ { CGPoint startPosition_; } +// XXX: To make BridgeSupport happy +-(void) startWithTarget:(id)target; @end /** An action that moves the target with a CatmullRom curve to a destination point. @@ -135,5 +137,13 @@ -(id) initWithDuration:(ccTime)dt points:(CCPointArray*)points; @end +#ifdef __cplusplus +extern "C" { +#endif + /** Returns the Cardinal Spline position for a given set of control points, tension and time */ - CGPoint ccCardinalSplineAt( CGPoint p0, CGPoint p1, CGPoint p2, CGPoint p3, CGFloat tension, ccTime t ); +CGPoint ccCardinalSplineAt( CGPoint p0, CGPoint p1, CGPoint p2, CGPoint p3, CGFloat tension, ccTime t ); + +#ifdef __cplusplus +} +#endif diff --git a/vendor/Pods/cocos2d/cocos2d/CCActionEase.h b/vendor/Pods/cocos2d/cocos2d/CCActionEase.h index 4c91e56..0ddaf6f 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCActionEase.h +++ b/vendor/Pods/cocos2d/cocos2d/CCActionEase.h @@ -54,34 +54,75 @@ /** CCEaseIn action with a rate */ -@interface CCEaseIn : CCEaseRateAction {} @end +@interface CCEaseIn : CCEaseRateAction +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end /** CCEaseOut action with a rate */ -@interface CCEaseOut : CCEaseRateAction {} @end +@interface CCEaseOut : CCEaseRateAction +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end /** CCEaseInOut action with a rate */ -@interface CCEaseInOut : CCEaseRateAction {} @end +@interface CCEaseInOut : CCEaseRateAction +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end /** CCEase Exponential In */ -@interface CCEaseExponentialIn : CCActionEase {} @end +@interface CCEaseExponentialIn : CCActionEase +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end + /** Ease Exponential Out */ -@interface CCEaseExponentialOut : CCActionEase {} @end +@interface CCEaseExponentialOut : CCActionEase +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end + /** Ease Exponential InOut */ -@interface CCEaseExponentialInOut : CCActionEase {} @end +@interface CCEaseExponentialInOut : CCActionEase +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end + /** Ease Sine In */ -@interface CCEaseSineIn : CCActionEase {} @end +@interface CCEaseSineIn : CCActionEase +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end + /** Ease Sine Out */ -@interface CCEaseSineOut : CCActionEase {} @end +@interface CCEaseSineOut : CCActionEase +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end + /** Ease Sine InOut */ -@interface CCEaseSineInOut : CCActionEase {} @end +@interface CCEaseSineInOut : CCActionEase +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end /** Ease Elastic abstract class @since v0.8.2 @@ -104,56 +145,98 @@ @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 */ -@interface CCEaseElasticIn : CCEaseElastic {} @end +@interface CCEaseElasticIn : CCEaseElastic +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end + /** Ease Elastic Out action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 */ -@interface CCEaseElasticOut : CCEaseElastic {} @end +@interface CCEaseElasticOut : CCEaseElastic +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end + /** Ease Elastic InOut action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 */ -@interface CCEaseElasticInOut : CCEaseElastic {} @end +@interface CCEaseElasticInOut : CCEaseElastic +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end /** CCEaseBounce abstract class. @since v0.8.2 */ -@interface CCEaseBounce : CCActionEase {} @end +@interface CCEaseBounce : CCActionEase +{} +// Needed for BridgeSupport +-(ccTime) bounceTime:(ccTime) t; +@end /** CCEaseBounceIn action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 */ -@interface CCEaseBounceIn : CCEaseBounce {} @end +@interface CCEaseBounceIn : CCEaseBounce +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end /** EaseBounceOut action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 */ -@interface CCEaseBounceOut : CCEaseBounce {} @end +@interface CCEaseBounceOut : CCEaseBounce +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end /** CCEaseBounceInOut action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 */ -@interface CCEaseBounceInOut : CCEaseBounce {} @end +@interface CCEaseBounceInOut : CCEaseBounce +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end /** CCEaseBackIn action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 */ -@interface CCEaseBackIn : CCActionEase {} @end +@interface CCEaseBackIn : CCActionEase +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end /** CCEaseBackOut action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 */ -@interface CCEaseBackOut : CCActionEase {} @end +@interface CCEaseBackOut : CCActionEase +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end /** CCEaseBackInOut action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 */ -@interface CCEaseBackInOut : CCActionEase {} @end +@interface CCEaseBackInOut : CCActionEase +{} +// Needed for BridgeSupport +-(void) update: (ccTime) t; +@end diff --git a/vendor/Pods/cocos2d/cocos2d/CCActionGrid3D.h b/vendor/Pods/cocos2d/cocos2d/CCActionGrid3D.h index 7e1c40e..6dbea0d 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCActionGrid3D.h +++ b/vendor/Pods/cocos2d/cocos2d/CCActionGrid3D.h @@ -64,7 +64,8 @@ @interface CCFlipY3D : CCFlipX3D { } - +// Needed for bridge support +-(void)update:(ccTime)time; @end //////////////////////////////////////////////////////////// diff --git a/vendor/Pods/cocos2d/cocos2d/CCActionInstant.h b/vendor/Pods/cocos2d/cocos2d/CCActionInstant.h index 928732b..cd8677f 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCActionInstant.h +++ b/vendor/Pods/cocos2d/cocos2d/CCActionInstant.h @@ -33,6 +33,8 @@ @interface CCActionInstant : CCFiniteTimeAction { } +// XXX Needed for BridgeSupport +-(id) init; @end /** Show the node @@ -40,6 +42,8 @@ @interface CCShow : CCActionInstant { } +// XXX Needed for BridgeSupport +-(void) update:(ccTime)time; @end /** Hide the node @@ -47,6 +51,7 @@ @interface CCHide : CCActionInstant { } +-(void) update:(ccTime)time; @end /** Toggles the visibility of a node @@ -54,6 +59,7 @@ @interface CCToggleVisibility : CCActionInstant { } +-(void) update:(ccTime)time; @end /** Flips the sprite horizontally @@ -115,6 +121,8 @@ @interface CCCallFuncN : CCCallFunc { } +// XXX: Needed for BridgeSupport +-(void) execute; @end typedef void (*CC_CALLBACK_ND)(id, SEL, id, void *); diff --git a/vendor/Pods/cocos2d/cocos2d/CCActionInterval.h b/vendor/Pods/cocos2d/cocos2d/CCActionInterval.h index ac3b38d..e6b4420 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCActionInterval.h +++ b/vendor/Pods/cocos2d/cocos2d/CCActionInterval.h @@ -76,6 +76,8 @@ then running it again in Reverse mode. } /** helper contructor to create an array of sequenceable actions */ +(id) actions: (CCFiniteTimeAction*) action1, ... NS_REQUIRES_NIL_TERMINATION; +/** helper contructor to create an array of sequenceable actions */ ++(id) actions: (CCFiniteTimeAction*) action1 vaList:(va_list) args; /** helper contructor to create an array of sequenceable actions given an array */ +(id) actionWithArray: (NSArray*) arrayOfActions; /** creates the action */ @@ -116,6 +118,8 @@ then running it again in Reverse mode. } /** helper constructor to create an array of spawned actions */ +(id) actions: (CCFiniteTimeAction*) action1, ... NS_REQUIRES_NIL_TERMINATION; +/** helper constructor to create an array of spawned actions */ ++(id) actions: (CCFiniteTimeAction*) action1 vaList:(va_list)args; /** helper contructor to create an array of spawned actions given an array */ +(id) actionWithArray: (NSArray*) arrayOfActions; /** creates the Spawn action */ @@ -130,27 +134,41 @@ then running it again in Reverse mode. */ @interface CCRotateTo : CCActionInterval { - float dstAngle_; - float startAngle_; - float diffAngle_; + float dstAngleX_; + float startAngleX_; + float diffAngleX_; + + float dstAngleY_; + float startAngleY_; + float diffAngleY_; } /** creates the action */ +(id) actionWithDuration:(ccTime)duration angle:(float)angle; /** initializes the action */ -(id) initWithDuration:(ccTime)duration angle:(float)angle; + +/** creates the action with seperate rotation angles */ ++(id) actionWithDuration: (ccTime) t angleX:(float) aX angleY:(float) aY; +-(id) initWithDuration: (ccTime) t angleX:(float) aX angleY:(float) aY; @end /** Rotates a CCNode object clockwise a number of degrees by modiying its rotation attribute. */ @interface CCRotateBy : CCActionInterval { - float angle_; - float startAngle_; + float angleX_; + float startAngleX_; + float angleY_; + float startAngleY_; } /** creates the action */ +(id) actionWithDuration:(ccTime)duration angle:(float)deltaAngle; /** initializes the action */ -(id) initWithDuration:(ccTime)duration angle:(float)deltaAngle; + +/** creates the action with seperate rotation angles */ ++(id) actionWithDuration: (ccTime) t angleX:(float) aX angleY:(float) aY; +-(id) initWithDuration: (ccTime) t angleX:(float) aX angleY:(float) aY; @end /** Moves a CCNode object to the position x,y. x and y are absolute coordinates by modifying its position attribute. @@ -196,7 +214,7 @@ then running it again in Reverse mode. } /** creates the action */ +(id) actionWithDuration:(ccTime)t skewX:(float)sx skewY:(float)sy; -/** initializes the action */ +/** initializes the action with duration, skew X and skew Y */ -(id) initWithDuration:(ccTime)t skewX:(float)sx skewY:(float)sy; @end @@ -206,11 +224,13 @@ then running it again in Reverse mode. @interface CCSkewBy : CCSkewTo { } +/** initializes the action with duration, skew X and skew Y */ +-(id) initWithDuration:(ccTime)t skewX:(float)sx skewY:(float)sy; @end /** Moves a CCNode object simulating a parabolic jump movement by modifying its position attribute. */ - @interface CCJumpBy : CCActionInterval +@interface CCJumpBy : CCActionInterval { CGPoint startPosition_; CGPoint delta_; @@ -225,9 +245,11 @@ then running it again in Reverse mode. /** Moves a CCNode object to a parabolic position simulating a jump movement by modifying its position attribute. */ - @interface CCJumpTo : CCJumpBy +@interface CCJumpTo : CCJumpBy { } +// XXX: Added to prevent bug on BridgeSupport +-(void) startWithTarget:(CCNode *)aTarget; @end /** bezier configuration structure @@ -262,6 +284,8 @@ typedef struct _ccBezierConfig { @interface CCBezierTo : CCBezierBy { } +// XXX: Added to prevent bug on BridgeSupport +-(void) startWithTarget:(CCNode *)aTarget; @end /** Scales a CCNode object to a zoom factor by modifying its scale attribute. @@ -293,6 +317,8 @@ typedef struct _ccBezierConfig { @interface CCScaleBy : CCScaleTo { } +// XXX: Added to prevent bug on BridgeSupport +-(void) startWithTarget:(CCNode *)aTarget; @end /** Blinks a CCNode object by modifying its visible attribute @@ -313,6 +339,8 @@ typedef struct _ccBezierConfig { @interface CCFadeIn : CCActionInterval { } +// XXX: Added to prevent bug on BridgeSupport +-(void) update:(ccTime)dt; @end /** Fades Out an object that implements the CCRGBAProtocol protocol. It modifies the opacity from 255 to 0. @@ -321,6 +349,8 @@ typedef struct _ccBezierConfig { @interface CCFadeOut : CCActionInterval { } +// XXX: Added to prevent bug on BridgeSupport +-(void) update:(ccTime)dt; @end /** Fades an object that implements the CCRGBAProtocol protocol. It modifies the opacity from the current value to a custom one. @@ -371,6 +401,8 @@ typedef struct _ccBezierConfig { @interface CCDelayTime : CCActionInterval { } +// XXX: Added to prevent bug on BridgeSupport +-(void) update:(ccTime)dt; @end /** Executes an action in reverse order, from time=duration to time=0 diff --git a/vendor/Pods/cocos2d/cocos2d/CCActionInterval.m b/vendor/Pods/cocos2d/cocos2d/CCActionInterval.m index b8a78d3..90e837b 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCActionInterval.m +++ b/vendor/Pods/cocos2d/cocos2d/CCActionInterval.m @@ -119,23 +119,33 @@ - (CCActionInterval*) reverse @implementation CCSequence +(id) actions: (CCFiniteTimeAction*) action1, ... { - va_list params; - va_start(params,action1); - + va_list args; + va_start(args, action1); + + id ret = [self actions:action1 vaList:args]; + + va_end(args); + + return ret; +} + ++(id) actions: (CCFiniteTimeAction*) action1 vaList:(va_list)args +{ CCFiniteTimeAction *now; CCFiniteTimeAction *prev = action1; while( action1 ) { - now = va_arg(params,CCFiniteTimeAction*); + now = va_arg(args,CCFiniteTimeAction*); if ( now ) prev = [self actionOne: prev two: now]; else break; } - va_end(params); + return prev; } + +(id) actionWithArray: (NSArray*) actions { CCFiniteTimeAction *prev = [actions objectAtIndex:0]; @@ -371,23 +381,32 @@ - (CCActionInterval *) reverse @implementation CCSpawn +(id) actions: (CCFiniteTimeAction*) action1, ... { - va_list params; - va_start(params,action1); + va_list args; + va_start(args, action1); + + id ret = [self actions:action1 vaList:args]; + + va_end(args); + return ret; +} ++(id) actions: (CCFiniteTimeAction*) action1 vaList:(va_list)args +{ CCFiniteTimeAction *now; CCFiniteTimeAction *prev = action1; - + while( action1 ) { - now = va_arg(params,CCFiniteTimeAction*); + now = va_arg(args,CCFiniteTimeAction*); if ( now ) prev = [self actionOne: prev two: now]; else break; } - va_end(params); + return prev; } + +(id) actionWithArray: (NSArray*) actions { CCFiniteTimeAction *prev = [actions objectAtIndex:0]; @@ -485,14 +504,28 @@ +(id) actionWithDuration: (ccTime) t angle:(float) a -(id) initWithDuration: (ccTime) t angle:(float) a { if( (self=[super initWithDuration: t]) ) - dstAngle_ = a; + dstAngleX_ = dstAngleY_ = a; + + return self; +} ++(id) actionWithDuration: (ccTime) t angleX:(float) aX angleY:(float) aY +{ + return [[[self alloc] initWithDuration:t angleX:aX angleY:aY ] autorelease]; +} + +-(id) initWithDuration: (ccTime) t angleX:(float) aX angleY:(float) aY +{ + if( (self=[super initWithDuration: t]) ){ + dstAngleX_ = aX; + dstAngleY_ = aY; + } return self; } -(id) copyWithZone: (NSZone*) zone { - CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration:[self duration] angle:dstAngle_]; + CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration:[self duration] angleX:dstAngleX_ angleY:dstAngleY_]; return copy; } @@ -500,21 +533,32 @@ -(void) startWithTarget:(CCNode *)aTarget { [super startWithTarget:aTarget]; - startAngle_ = [target_ rotation]; - if (startAngle_ > 0) - startAngle_ = fmodf(startAngle_, 360.0f); + //Calculate X + startAngleX_ = [target_ rotationX]; + + diffAngleX_ = dstAngleX_ - startAngleX_; + if (diffAngleX_ > 180) + diffAngleX_ -= 360; + if (diffAngleX_ < -180) + diffAngleX_ += 360; + + //Calculate Y + startAngleY_ = [target_ rotationY]; + if (startAngleY_ > 0) + startAngleY_ = fmodf(startAngleY_, 360.0f); else - startAngle_ = fmodf(startAngle_, -360.0f); - - diffAngle_ =dstAngle_ - startAngle_; - if (diffAngle_ > 180) - diffAngle_ -= 360; - if (diffAngle_ < -180) - diffAngle_ += 360; + startAngleY_ = fmodf(startAngleY_, -360.0f); + + diffAngleY_ = dstAngleY_ - startAngleY_; + if (diffAngleY_ > 180) + diffAngleY_ -= 360; + if (diffAngleY_ < -180) + diffAngleY_ += 360; } -(void) update: (ccTime) t { - [target_ setRotation: startAngle_ + diffAngle_ * t]; + [target_ setRotationX: startAngleX_ + diffAngleX_ * t]; + [target_ setRotationY: startAngleY_ + diffAngleY_ * t]; } @end @@ -522,7 +566,7 @@ -(void) update: (ccTime) t // // RotateBy // -#pragma mark - CCRotateBy +#pragma mark - RotateBy @implementation CCRotateBy +(id) actionWithDuration: (ccTime) t angle:(float) a @@ -533,32 +577,48 @@ +(id) actionWithDuration: (ccTime) t angle:(float) a -(id) initWithDuration: (ccTime) t angle:(float) a { if( (self=[super initWithDuration: t]) ) - angle_ = a; + angleX_ = angleY_ = a; + + return self; +} ++(id) actionWithDuration: (ccTime) t angleX:(float) aX angleY:(float) aY +{ + return [[[self alloc] initWithDuration:t angleX:aX angleY:aY ] autorelease]; +} + +-(id) initWithDuration: (ccTime) t angleX:(float) aX angleY:(float) aY +{ + if( (self=[super initWithDuration: t]) ){ + angleX_ = aX; + angleY_ = aY; + } return self; } -(id) copyWithZone: (NSZone*) zone { - CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration: [self duration] angle: angle_]; + CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration: [self duration] angleX: angleX_ angleY:angleY_]; return copy; } -(void) startWithTarget:(id)aTarget { [super startWithTarget:aTarget]; - startAngle_ = [target_ rotation]; + startAngleX_ = [target_ rotationX]; + startAngleY_ = [target_ rotationY]; } -(void) update: (ccTime) t { // XXX: shall I add % 360 - [target_ setRotation: (startAngle_ +angle_ * t )]; + [target_ setRotationX: (startAngleX_ + angleX_ * t )]; + [target_ setRotationY: (startAngleY_ + angleY_ * t )]; } -(CCActionInterval*) reverse { - return [[self class] actionWithDuration:duration_ angle:-angle_]; + return [[self class] actionWithDuration:duration_ angleX:-angleX_ angleY:-angleY_]; } @end diff --git a/vendor/Pods/cocos2d/cocos2d/CCDirector.m b/vendor/Pods/cocos2d/cocos2d/CCDirector.m index 3e3e253..74bfa03 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCDirector.m +++ b/vendor/Pods/cocos2d/cocos2d/CCDirector.m @@ -276,11 +276,10 @@ -(void) setProjection:(ccDirectorProjection)projection - (void) setAlphaBlending: (BOOL) on { if (on) { - ccGLEnable(CC_GL_BLEND); ccGLBlendFunc(CC_BLEND_SRC, CC_BLEND_DST); } else - glDisable(GL_BLEND); + ccGLBlendFunc(GL_ONE, GL_ZERO); CHECK_GL_ERROR_DEBUG(); } @@ -367,6 +366,7 @@ -(void) reshapeProjection:(CGSize)newWindowSize - (void)runWithScene:(CCScene*) scene { NSAssert( scene != nil, @"Argument must be non-nil"); + NSAssert(runningScene_ == nil, @"This command can only be used to start the CCDirector. There is already a scene present."); [self pushScene:scene]; [self startAnimation]; @@ -374,6 +374,7 @@ - (void)runWithScene:(CCScene*) scene -(void) replaceScene: (CCScene*) scene { + NSAssert( runningScene_, @"Use runWithScene: instead to start the director"); NSAssert( scene != nil, @"Argument must be non-nil"); NSUInteger index = [scenesStack_ count]; diff --git a/vendor/Pods/cocos2d/cocos2d/CCDrawNode.h b/vendor/Pods/cocos2d/cocos2d/CCDrawNode.h new file mode 100644 index 0000000..9a190da --- /dev/null +++ b/vendor/Pods/cocos2d/cocos2d/CCDrawNode.h @@ -0,0 +1,65 @@ +/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * Code copied & pasted from SpacePatrol game https://github.com/slembcke/SpacePatrol + * + * Renamed and added some changes for cocos2d + * + */ + +#import "CCNode.h" + +/** CCDrawNode + Node that draws dots, segments and polygons. + Faster than the "drawing primitives" since they it draws everything in one single batch. + + @since v2.1 + */ +@interface CCDrawNode : CCNode +{ + GLuint _vao; + GLuint _vbo; + + NSUInteger _bufferCapacity; + GLsizei _bufferCount; + ccV2F_C4B_T2F *_buffer; + + ccBlendFunc _blendFunc; + + BOOL _dirty; +} + +@property(nonatomic, assign) ccBlendFunc blendFunc; + +/** draw a dot at a position, with a given radius and color */ +-(void)drawDot:(CGPoint)pos radius:(CGFloat)radius color:(ccColor4F)color; + +/** draw a segment with a radius and color */ +-(void)drawSegmentFrom:(CGPoint)a to:(CGPoint)b radius:(CGFloat)radius color:(ccColor4F)color; + +/** draw a polygon with a fill color and line color */ +-(void)drawPolyWithVerts:(CGPoint*)verts count:(NSUInteger)count fillColor:(ccColor4F)fill borderWidth:(CGFloat)width borderColor:(ccColor4F)line; + +/** Clear the geometry in the node's buffer. */ +-(void)clear; + +@end diff --git a/vendor/Pods/cocos2d/cocos2d/CCDrawNode.m b/vendor/Pods/cocos2d/cocos2d/CCDrawNode.m new file mode 100644 index 0000000..60f2df3 --- /dev/null +++ b/vendor/Pods/cocos2d/cocos2d/CCDrawNode.m @@ -0,0 +1,377 @@ +/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * Code copied & pasted from SpacePatrol game https://github.com/slembcke/SpacePatrol + * + * Renamed and added some changes for cocos2d + * + */ + +#import "CCDrawNode.h" +#import "CCShaderCache.h" +#import "CCGLProgram.h" +#import "Support/CGPointExtension.h" +#import "Support/OpenGL_Internal.h" + + +// ccVertex2F == CGPoint in 32-bits, but not in 64-bits (OS X) +// that's why the "v2f" functions are needed +static ccVertex2F v2fzero = (ccVertex2F){0,0}; + +static inline ccVertex2F v2f( float x, float y ) +{ + return (ccVertex2F){x,y}; +} + +static inline ccVertex2F v2fadd( ccVertex2F v0, ccVertex2F v1 ) +{ + return v2f( v0.x+v1.x, v0.y+v1.y ); +} + +static inline ccVertex2F v2fsub( ccVertex2F v0, ccVertex2F v1 ) +{ + return v2f( v0.x-v1.x, v0.y-v1.y ); +} + +static inline ccVertex2F v2fmult( ccVertex2F v, float s ) +{ + return v2f( v.x * s, v.y * s ); +} + +static inline ccVertex2F v2fperp( ccVertex2F p0 ) +{ + return v2f( -p0.y, p0.x ); +} + +static inline ccVertex2F v2fneg( ccVertex2F p0 ) +{ + return v2f( -p0.x, - p0.y ); +} + +static inline float v2fdot(ccVertex2F p0, ccVertex2F p1) +{ + return p0.x * p1.x + p0.y * p1.y; +} + +static inline ccVertex2F v2fforangle( float _a_) +{ + return v2f( cosf(_a_), sinf(_a_) ); +} + +static inline ccVertex2F v2fnormalize( ccVertex2F p ) +{ + CGPoint r = ccpNormalize( ccp(p.x, p.y) ); + return v2f( r.x, r.y); +} + +static inline ccVertex2F __v2f(CGPoint v ) +{ +#ifdef __LP64__ + return v2f(v.x, v.y); +#else + return * ((ccVertex2F*) &v); +#endif +} + +static inline ccTex2F __t(ccVertex2F v ) +{ + return *(ccTex2F*)&v; +} + + +@implementation CCDrawNode + +@synthesize blendFunc = _blendFunc; + +#pragma mark memory + +-(void)ensureCapacity:(NSUInteger)count +{ + if(_bufferCount + count > _bufferCapacity){ + _bufferCapacity += MAX(_bufferCapacity, count); + _buffer = realloc(_buffer, _bufferCapacity*sizeof(ccV2F_C4B_T2F)); + +// NSLog(@"Resized vertex buffer to %d", _bufferCapacity); + } +} + +-(id)init +{ + if((self = [super init])){ + self.blendFunc = (ccBlendFunc){CC_BLEND_SRC, CC_BLEND_DST}; + + self.shaderProgram = [[CCShaderCache sharedShaderCache] programForKey:kCCShader_PositionLengthTexureColor]; + + [self ensureCapacity:512]; + + glGenVertexArrays(1, &_vao); + ccGLBindVAO(_vao); + + glGenBuffers(1, &_vbo); + glBindBuffer(GL_ARRAY_BUFFER, _vbo); + glBufferData(GL_ARRAY_BUFFER, sizeof(ccV2F_C4B_T2F)*_bufferCapacity, _buffer, GL_STREAM_DRAW); + + glEnableVertexAttribArray(kCCVertexAttrib_Position); + glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid *)offsetof(ccV2F_C4B_T2F, vertices)); + + glEnableVertexAttribArray(kCCVertexAttrib_Color); + glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ccV2F_C4B_T2F), (GLvoid *)offsetof(ccV2F_C4B_T2F, colors)); + + glEnableVertexAttribArray(kCCVertexAttrib_TexCoords); + glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid *)offsetof(ccV2F_C4B_T2F, texCoords)); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + ccGLBindVAO(0); + + CHECK_GL_ERROR(); + + _dirty = YES; + } + + return self; +} + +-(void)dealloc +{ +#ifdef __CC_PLATFORM_IOS + NSAssert([EAGLContext currentContext], @"No GL context set!"); +#endif + + free(_buffer); _buffer = NULL; + + glDeleteBuffers(1, &_vbo); _vbo = 0; + glDeleteVertexArrays(1, &_vao); _vao = 0; + + [super dealloc]; +} + +#pragma mark Rendering + +-(void)render +{ + if( _dirty ) { + glBindBuffer(GL_ARRAY_BUFFER, _vbo); + glBufferData(GL_ARRAY_BUFFER, sizeof(ccV2F_C4B_T2F)*_bufferCapacity, _buffer, GL_STREAM_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + _dirty = NO; + } + + ccGLBindVAO(_vao); + glDrawArrays(GL_TRIANGLES, 0, _bufferCount); + + CC_INCREMENT_GL_DRAWS(1); + + CHECK_GL_ERROR(); +} + +-(void)draw +{ + ccGLBlendFunc(_blendFunc.src, _blendFunc.dst); + + [shaderProgram_ use]; + [shaderProgram_ setUniformsForBuiltins]; + + [self render]; +} + +#pragma mark Immediate Mode + +-(void)drawDot:(CGPoint)pos radius:(CGFloat)radius color:(ccColor4F)color; +{ + NSUInteger vertex_count = 2*3; + [self ensureCapacity:vertex_count]; + + ccV2F_C4B_T2F a = {{pos.x - radius, pos.y - radius}, ccc4BFromccc4F(color), {-1.0, -1.0} }; + ccV2F_C4B_T2F b = {{pos.x - radius, pos.y + radius}, ccc4BFromccc4F(color), {-1.0, 1.0} }; + ccV2F_C4B_T2F c = {{pos.x + radius, pos.y + radius}, ccc4BFromccc4F(color), { 1.0, 1.0} }; + ccV2F_C4B_T2F d = {{pos.x + radius, pos.y - radius}, ccc4BFromccc4F(color), { 1.0, -1.0} }; + + ccV2F_C4B_T2F_Triangle *triangles = (ccV2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); + triangles[0] = (ccV2F_C4B_T2F_Triangle){a, b, c}; + triangles[1] = (ccV2F_C4B_T2F_Triangle){a, c, d}; + + _bufferCount += vertex_count; + + _dirty = YES; +} + +-(void)drawSegmentFrom:(CGPoint)_a to:(CGPoint)_b radius:(CGFloat)radius color:(ccColor4F)color; +{ + NSUInteger vertex_count = 6*3; + [self ensureCapacity:vertex_count]; + + ccVertex2F a = __v2f(_a); + ccVertex2F b = __v2f(_b); + + + ccVertex2F n = v2fnormalize(v2fperp(v2fsub(b, a))); + ccVertex2F t = v2fperp(n); + + ccVertex2F nw = v2fmult(n, radius); + ccVertex2F tw = v2fmult(t, radius); + ccVertex2F v0 = v2fsub(b, v2fadd(nw, tw)); + ccVertex2F v1 = v2fadd(b, v2fsub(nw, tw)); + ccVertex2F v2 = v2fsub(b, nw); + ccVertex2F v3 = v2fadd(b, nw); + ccVertex2F v4 = v2fsub(a, nw); + ccVertex2F v5 = v2fadd(a, nw); + ccVertex2F v6 = v2fsub(a, v2fsub(nw, tw)); + ccVertex2F v7 = v2fadd(a, v2fadd(nw, tw)); + + + ccV2F_C4B_T2F_Triangle *triangles = (ccV2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); + + triangles[0] = (ccV2F_C4B_T2F_Triangle) { + {v0, ccc4BFromccc4F(color), __t(v2fneg(v2fadd(n, t))) }, + {v1, ccc4BFromccc4F(color), __t(v2fsub(n, t)) }, + {v2, ccc4BFromccc4F(color), __t(v2fneg(n)) }, + }; + + triangles[1] = (ccV2F_C4B_T2F_Triangle){ + {v3, ccc4BFromccc4F(color), __t(n)}, + {v1, ccc4BFromccc4F(color), __t(v2fsub(n, t)) }, + {v2, ccc4BFromccc4F(color), __t(v2fneg(n)) }, + }; + + triangles[2] = (ccV2F_C4B_T2F_Triangle){ + {v3, ccc4BFromccc4F(color), __t(n)}, + {v4, ccc4BFromccc4F(color), __t(v2fneg(n)) }, + {v2, ccc4BFromccc4F(color), __t(v2fneg(n)) }, + }; + triangles[3] = (ccV2F_C4B_T2F_Triangle){ + {v3, ccc4BFromccc4F(color), __t(n) }, + {v4, ccc4BFromccc4F(color), __t(v2fneg(n)) }, + {v5, ccc4BFromccc4F(color), __t(n) }, + }; + triangles[4] = (ccV2F_C4B_T2F_Triangle){ + {v6, ccc4BFromccc4F(color), __t(v2fsub(t, n))}, + {v4, ccc4BFromccc4F(color), __t(v2fneg(n)) }, + {v5, ccc4BFromccc4F(color), __t(n)}, + }; + triangles[5] = (ccV2F_C4B_T2F_Triangle){ + {v6, ccc4BFromccc4F(color), __t(v2fsub(t, n)) }, + {v7, ccc4BFromccc4F(color), __t(v2fadd(n, t)) }, + {v5, ccc4BFromccc4F(color), __t(n)}, + }; + + _bufferCount += vertex_count; + + _dirty = YES; +} + +-(void)drawPolyWithVerts:(CGPoint *)verts count:(NSUInteger)count fillColor:(ccColor4F)fill borderWidth:(CGFloat)width borderColor:(ccColor4F)line; +{ + struct ExtrudeVerts {ccVertex2F offset, n;}; + struct ExtrudeVerts extrude[count]; + bzero(extrude, sizeof(extrude) ); + + for(int i=0; i 0.0 && width > 0.0); + + NSUInteger triangle_count = 3*count - 2; + NSUInteger vertex_count = 3*triangle_count; + [self ensureCapacity:vertex_count]; + + ccV2F_C4B_T2F_Triangle *triangles = (ccV2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); + ccV2F_C4B_T2F_Triangle *cursor = triangles; + + CGFloat inset = (outline == 0.0 ? 0.5 : 0.0); + for(int i=0; i #import #import @@ -70,7 +81,7 @@ void ccDrawPoint( CGPoint point ) ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); [shader_ use]; - [shader_ setUniformForModelViewProjectionMatrix]; + [shader_ setUniformsForBuiltins]; [shader_ setUniformLocation:colorLocation_ with4fv:(GLfloat*) &color_.r count:1]; [shader_ setUniformLocation:pointSizeLocation_ withF1:pointSize_]; @@ -89,7 +100,7 @@ void ccDrawPoints( const CGPoint *points, NSUInteger numberOfPoints ) ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); [shader_ use]; - [shader_ setUniformForModelViewProjectionMatrix]; + [shader_ setUniformsForBuiltins]; [shader_ setUniformLocation:colorLocation_ with4fv:(GLfloat*) &color_.r count:1]; [shader_ setUniformLocation:pointSizeLocation_ withF1:pointSize_]; @@ -125,7 +136,7 @@ void ccDrawLine( CGPoint origin, CGPoint destination ) }; [shader_ use]; - [shader_ setUniformForModelViewProjectionMatrix]; + [shader_ setUniformsForBuiltins]; [shader_ setUniformLocation:colorLocation_ with4fv:(GLfloat*) &color_.r count:1]; ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); @@ -160,7 +171,7 @@ void ccDrawPoly( const CGPoint *poli, NSUInteger numberOfPoints, BOOL closePolyg lazy_init(); [shader_ use]; - [shader_ setUniformForModelViewProjectionMatrix]; + [shader_ setUniformsForBuiltins]; [shader_ setUniformLocation:colorLocation_ with4fv:(GLfloat*) &color_.r count:1]; ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); @@ -194,7 +205,7 @@ void ccDrawSolidPoly( const CGPoint *poli, NSUInteger numberOfPoints, ccColor4F lazy_init(); [shader_ use]; - [shader_ setUniformForModelViewProjectionMatrix]; + [shader_ setUniformsForBuiltins]; [shader_ setUniformLocation:colorLocation_ with4fv:(GLfloat*) &color.r count:1]; ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); @@ -245,7 +256,7 @@ void ccDrawCircle( CGPoint center, float r, float a, NSUInteger segs, BOOL drawL vertices[(segs+1)*2+1] = center.y; [shader_ use]; - [shader_ setUniformForModelViewProjectionMatrix]; + [shader_ setUniformsForBuiltins]; [shader_ setUniformLocation:colorLocation_ with4fv:(GLfloat*) &color_.r count:1]; ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); @@ -274,7 +285,7 @@ void ccDrawQuadBezier(CGPoint origin, CGPoint control, CGPoint destination, NSUI vertices[segments] = (ccVertex2F) {destination.x, destination.y}; [shader_ use]; - [shader_ setUniformForModelViewProjectionMatrix]; + [shader_ setUniformsForBuiltins]; [shader_ setUniformLocation:colorLocation_ with4fv:(GLfloat*) &color_.r count:1]; ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); @@ -325,7 +336,7 @@ void ccDrawCardinalSpline( CCPointArray *config, CGFloat tension, NSUInteger se } [shader_ use]; - [shader_ setUniformForModelViewProjectionMatrix]; + [shader_ setUniformsForBuiltins]; [shader_ setUniformLocation:colorLocation_ with4fv:(GLfloat*) &color_.r count:1]; ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); @@ -352,7 +363,7 @@ void ccDrawCubicBezier(CGPoint origin, CGPoint control1, CGPoint control2, CGPoi vertices[segments] = (ccVertex2F) {destination.x, destination.y}; [shader_ use]; - [shader_ setUniformForModelViewProjectionMatrix]; + [shader_ setUniformsForBuiltins]; [shader_ setUniformLocation:colorLocation_ with4fv:(GLfloat*) &color_.r count:1]; ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); diff --git a/vendor/Pods/cocos2d/cocos2d/CCGLProgram.h b/vendor/Pods/cocos2d/cocos2d/CCGLProgram.h index 7ac34dd..71577b7 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCGLProgram.h +++ b/vendor/Pods/cocos2d/cocos2d/CCGLProgram.h @@ -40,7 +40,13 @@ enum { }; enum { + kCCUniformPMatrix, + kCCUniformMVMatrix, kCCUniformMVPMatrix, + kCCUniformTime, + kCCUniformSinTime, + kCCUniformCosTime, + kCCUniformRandom01, kCCUniformSampler, kCCUniform_MAX, @@ -53,11 +59,18 @@ enum { #define kCCShader_PositionTexture_uColor @"ShaderPositionTexture_uColor" #define kCCShader_PositionTextureA8Color @"ShaderPositionTextureA8Color" #define kCCShader_Position_uColor @"ShaderPosition_uColor" +#define kCCShader_PositionLengthTexureColor @"ShaderPositionLengthTextureColor" // uniform names -#define kCCUniformMVPMatrix_s "u_MVPMatrix" -#define kCCUniformSampler_s "u_texture" -#define kCCUniformAlphaTestValue "u_alpha_value" +#define kCCUniformPMatrix_s "CC_PMatrix" +#define kCCUniformMVMatrix_s "CC_MVMatrix" +#define kCCUniformMVPMatrix_s "CC_MVPMatrix" +#define kCCUniformTime_s "CC_Time" +#define kCCUniformSinTime_s "CC_SinTime" +#define kCCUniformCosTime_s "CC_CosTime" +#define kCCUniformRandom01_s "CC_Random01" +#define kCCUniformSampler_s "CC_Texture0" +#define kCCUniformAlphaTestValue "CC_alpha_value" // Attribute names #define kCCAttributeNameColor @"a_color" @@ -83,8 +96,11 @@ struct _hashUniformEntry; fragShader_; GLint uniforms_[kCCUniform_MAX]; + BOOL usesTime_; } +@property(nonatomic, readonly) GLuint program; + /** Initializes the CCGLProgram with a vertex and fragment with bytes array */ - (id)initWithVertexShaderByteArray:(const GLchar*)vShaderByteArray fragmentShaderByteArray:(const GLchar*)fShaderByteArray; @@ -100,9 +116,10 @@ struct _hashUniformEntry; /** it will call glUseProgram() */ - (void)use; -/** It will create 3 uniforms: +/** It will create 4 uniforms: - kCCUniformPMatrix - kCCUniformMVMatrix + - kCCUniformMVPMatrix - kCCUniformSampler And it will bind "kCCUniformSampler" to 0 @@ -110,34 +127,37 @@ struct _hashUniformEntry; - (void) updateUniforms; /** calls glUniform1i only if the values are different than the previous call for this same shader program. */ --(void) setUniformLocation:(NSUInteger)location withI1:(GLint)i1; +-(void) setUniformLocation:(GLint)location withI1:(GLint)i1; /** calls glUniform1f only if the values are different than the previous call for this same shader program. */ --(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1; +-(void) setUniformLocation:(GLint)location withF1:(GLfloat)f1; /** calls glUniform2f only if the values are different than the previous call for this same shader program. */ --(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1 f2:(GLfloat)f2; +-(void) setUniformLocation:(GLint)location withF1:(GLfloat)f1 f2:(GLfloat)f2; /** calls glUniform3f only if the values are different than the previous call for this same shader program. */ --(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1 f2:(GLfloat)f2 f3:(GLfloat)f3; +-(void) setUniformLocation:(GLint)location withF1:(GLfloat)f1 f2:(GLfloat)f2 f3:(GLfloat)f3; /** calls glUniform4f only if the values are different than the previous call for this same shader program. */ --(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1 f2:(GLfloat)f2 f3:(GLfloat)f3 f4:(GLfloat)f4; +-(void) setUniformLocation:(GLint)location withF1:(GLfloat)f1 f2:(GLfloat)f2 f3:(GLfloat)f3 f4:(GLfloat)f4; /** calls glUniform2fv only if the values are different than the previous call for this same shader program. */ --(void) setUniformLocation:(NSUInteger)location with2fv:(GLfloat*)floats count:(NSUInteger)numberOfArrays; +-(void) setUniformLocation:(GLint)location with2fv:(GLfloat*)floats count:(NSUInteger)numberOfArrays; /** calls glUniform3fv only if the values are different than the previous call for this same shader program. */ --(void) setUniformLocation:(NSUInteger)location with3fv:(GLfloat*)floats count:(NSUInteger)numberOfArrays; +-(void) setUniformLocation:(GLint)location with3fv:(GLfloat*)floats count:(NSUInteger)numberOfArrays; /** calls glUniform4fv only if the values are different than the previous call for this same shader program. */ --(void) setUniformLocation:(NSUInteger)location with4fv:(GLvoid*)floats count:(NSUInteger)numberOfArrays; +-(void) setUniformLocation:(GLint)location with4fv:(GLvoid*)floats count:(NSUInteger)numberOfArrays; /** calls glUniformMatrix4fv only if the values are different than the previous call for this same shader program. */ --(void) setUniformLocation:(NSUInteger)location withMatrix4fv:(GLvoid*)matrix_array count:(NSUInteger)numberOfMatrix; +-(void) setUniformLocation:(GLint)location withMatrix4fv:(GLvoid*)matrix_array count:(NSUInteger)numberOfMatrix; + +/** will update the builtin uniforms if they are different than the previous call for this same shader program. */ +-(void) setUniformsForBuiltins; -/** will update the MVP matrix on the MVP uniform if it is different than the previous call for this same shader program. */ --(void) setUniformForModelViewProjectionMatrix; +/** Deprecated alias for setUniformsForBuiltins */ +-(void)setUniformForModelViewProjectionMatrix __attribute__((__deprecated__)); /** returns the vertexShader error log */ - (NSString *)vertexShaderLog; diff --git a/vendor/Pods/cocos2d/cocos2d/CCGLProgram.m b/vendor/Pods/cocos2d/cocos2d/CCGLProgram.m index 1c0f489..9c63e68 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCGLProgram.m +++ b/vendor/Pods/cocos2d/cocos2d/CCGLProgram.m @@ -33,6 +33,8 @@ #import "Support/uthash.h" #import "Support/OpenGL_Internal.h" +#import "CCDirector.h" + // extern #import "kazmath/GL/matrix.h" #import "kazmath/kazmath.h" @@ -66,6 +68,9 @@ - (NSString *)logForOpenGLObject:(GLuint)object infoCallback:(GLInfoFunction)inf #pragma mark - @implementation CCGLProgram + +@synthesize program = program_; + - (id)initWithVertexShaderByteArray:(const GLchar *)vShaderByteArray fragmentShaderByteArray:(const GLchar *)fShaderByteArray { if ((self = [super init]) ) @@ -124,19 +129,42 @@ - (BOOL)compileShader:(GLuint *)shader type:(GLenum)type byteArray:(const GLchar if (!source) return NO; - + + const GLchar *sources[] = { +#ifdef __CC_PLATFORM_IOS + (type == GL_VERTEX_SHADER ? "precision highp float;\n" : "precision mediump float;\n"), +#endif + "uniform mat4 CC_PMatrix;\n" + "uniform mat4 CC_MVMatrix;\n" + "uniform mat4 CC_MVPMatrix;\n" + "uniform vec4 CC_Time;\n" + "uniform vec4 CC_SinTime;\n" + "uniform vec4 CC_CosTime;\n" + "uniform vec4 CC_Random01;\n" + "//CC INCLUDES END\n\n", + source, + }; + *shader = glCreateShader(type); - glShaderSource(*shader, 1, &source, NULL); + glShaderSource(*shader, sizeof(sources)/sizeof(*sources), sources, NULL); glCompileShader(*shader); glGetShaderiv(*shader, GL_COMPILE_STATUS, &status); if( ! status ) { + GLsizei length; + glGetShaderiv(*shader, GL_SHADER_SOURCE_LENGTH, &length); + GLchar src[length]; + + glGetShaderSource(*shader, length, NULL, src); + CCLOG(@"cocos2d: ERROR: Failed to compile shader:\n%s", src); + if( type == GL_VERTEX_SHADER ) CCLOG(@"cocos2d: %@", [self vertexShaderLog] ); else CCLOG(@"cocos2d: %@", [self fragmentShaderLog] ); + abort(); } return ( status == GL_TRUE ); } @@ -152,14 +180,27 @@ - (void)addAttribute:(NSString *)attributeName index:(GLuint)index -(void) updateUniforms { - // Since sample most probably won't change, set it to 0 now. - + uniforms_[ kCCUniformPMatrix] = glGetUniformLocation(program_, kCCUniformPMatrix_s); + uniforms_[ kCCUniformMVMatrix] = glGetUniformLocation(program_, kCCUniformMVMatrix_s); uniforms_[kCCUniformMVPMatrix] = glGetUniformLocation(program_, kCCUniformMVPMatrix_s); + + uniforms_[kCCUniformTime] = glGetUniformLocation(program_, kCCUniformTime_s); + uniforms_[kCCUniformSinTime] = glGetUniformLocation(program_, kCCUniformSinTime_s); + uniforms_[kCCUniformCosTime] = glGetUniformLocation(program_, kCCUniformCosTime_s); + + usesTime_ = ( + uniforms_[kCCUniformTime] != -1 || + uniforms_[kCCUniformSinTime] != -1 || + uniforms_[kCCUniformCosTime] != -1 + ); + uniforms_[kCCUniformRandom01] = glGetUniformLocation(program_, kCCUniformRandom01_s); + uniforms_[kCCUniformSampler] = glGetUniformLocation(program_, kCCUniformSampler_s); [self use]; + // Since sample most probably won't change, set it to 0 now. [self setUniformLocation:uniforms_[kCCUniformSampler] withI1:0]; } @@ -171,64 +212,54 @@ - (BOOL)link #if DEBUG GLint status; - glValidateProgram(program_); + glValidateProgram(program_); - glGetProgramiv(program_, GL_LINK_STATUS, &status); - if (status == GL_FALSE) { - CCLOG(@"cocos2d: ERROR: Failed to link program: %i", program_); - if( vertShader_ ) - glDeleteShader( vertShader_ ); - if( fragShader_ ) - glDeleteShader( fragShader_ ); - ccGLDeleteProgram( program_ ); - vertShader_ = fragShader_ = program_ = 0; - return NO; - } + glGetProgramiv(program_, GL_LINK_STATUS, &status); + NSAssert(status == GL_TRUE, @"cocos2d: ERROR: Failed to link program: %i", program_); #endif - if (vertShader_) - glDeleteShader(vertShader_); - if (fragShader_) - glDeleteShader(fragShader_); + if (vertShader_) + glDeleteShader(vertShader_); + if (fragShader_) + glDeleteShader(fragShader_); vertShader_ = fragShader_ = 0; - return YES; + return YES; } - (void)use { - ccGLUseProgram(program_); + ccGLUseProgram(program_); } #pragma mark - - (NSString *)logForOpenGLObject:(GLuint)object - infoCallback:(GLInfoFunction)infoFunc - logFunc:(GLLogFunction)logFunc + infoCallback:(GLInfoFunction)infoFunc + logFunc:(GLLogFunction)logFunc { - GLint logLength = 0, charsWritten = 0; - - infoFunc(object, GL_INFO_LOG_LENGTH, &logLength); - if (logLength < 1) - return nil; - - char *logBytes = malloc(logLength); - logFunc(object, logLength, &charsWritten, logBytes); - NSString *log = [[[NSString alloc] initWithBytes:logBytes - length:logLength - encoding:NSUTF8StringEncoding] - autorelease]; - free(logBytes); - return log; + GLint logLength = 0, charsWritten = 0; + + infoFunc(object, GL_INFO_LOG_LENGTH, &logLength); + if (logLength < 1) + return nil; + + char *logBytes = malloc(logLength); + logFunc(object, logLength, &charsWritten, logBytes); + NSString *log = [[[NSString alloc] initWithBytes:logBytes + length:logLength + encoding:NSUTF8StringEncoding] + autorelease]; + free(logBytes); + return log; } - (NSString *)vertexShaderLog { - return [self logForOpenGLObject:vertShader_ - infoCallback:(GLInfoFunction)&glGetShaderiv - logFunc:(GLLogFunction)&glGetShaderInfoLog]; - + return [self logForOpenGLObject:vertShader_ + infoCallback:(GLInfoFunction)&glGetShaderiv + logFunc:(GLLogFunction)&glGetShaderInfoLog]; } - (NSString *)fragmentShaderLog @@ -240,19 +271,22 @@ - (NSString *)fragmentShaderLog - (NSString *)programLog { - return [self logForOpenGLObject:program_ - infoCallback:(GLInfoFunction)&glGetProgramiv - logFunc:(GLLogFunction)&glGetProgramInfoLog]; + return [self logForOpenGLObject:program_ + infoCallback:(GLInfoFunction)&glGetProgramiv + logFunc:(GLLogFunction)&glGetProgramInfoLog]; } #pragma mark - Uniform cache --(BOOL) updateUniformLocation:(NSUInteger)location withData:(GLvoid*)data sizeOfData:(NSUInteger)bytes +-(BOOL) updateUniformLocation:(GLint)location withData:(GLvoid*)data sizeOfData:(NSUInteger)bytes { + if(location < 0) + return FALSE; + BOOL updated = YES; tHashUniformEntry *element = NULL; HASH_FIND_INT(hashForUniforms_, &location, element); - + if( ! element ) { element = malloc( sizeof(*element) ); @@ -273,11 +307,11 @@ -(BOOL) updateUniformLocation:(NSUInteger)location withData:(GLvoid*)data sizeOf else memcpy( element->value, data, bytes ); } - + return updated; } --(void) setUniformLocation:(NSUInteger)location withI1:(GLint)i1 +-(void) setUniformLocation:(GLint)location withI1:(GLint)i1 { BOOL updated = [self updateUniformLocation:location withData:&i1 sizeOfData:sizeof(i1)*1]; @@ -285,7 +319,7 @@ -(void) setUniformLocation:(NSUInteger)location withI1:(GLint)i1 glUniform1i( (GLint)location, i1); } --(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1 +-(void) setUniformLocation:(GLint)location withF1:(GLfloat)f1 { BOOL updated = [self updateUniformLocation:location withData:&f1 sizeOfData:sizeof(f1)*1]; @@ -293,7 +327,7 @@ -(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1 glUniform1f( (GLint)location, f1); } --(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1 f2:(GLfloat)f2 +-(void) setUniformLocation:(GLint)location withF1:(GLfloat)f1 f2:(GLfloat)f2 { GLfloat floats[2] = {f1,f2}; BOOL updated = [self updateUniformLocation:location withData:floats sizeOfData:sizeof(floats)]; @@ -302,7 +336,7 @@ -(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1 f2:(GLfloat)f glUniform2f( (GLint)location, f1, f2); } --(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1 f2:(GLfloat)f2 f3:(GLfloat)f3 +-(void) setUniformLocation:(GLint)location withF1:(GLfloat)f1 f2:(GLfloat)f2 f3:(GLfloat)f3 { GLfloat floats[3] = {f1,f2,f3}; BOOL updated = [self updateUniformLocation:location withData:floats sizeOfData:sizeof(floats)]; @@ -311,7 +345,7 @@ -(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1 f2:(GLfloat)f glUniform3f( (GLint)location, f1, f2, f3); } --(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1 f2:(GLfloat)f2 f3:(GLfloat)f3 f4:(GLfloat)f4 +-(void) setUniformLocation:(GLint)location withF1:(GLfloat)f1 f2:(GLfloat)f2 f3:(GLfloat)f3 f4:(GLfloat)f4 { GLfloat floats[4] = {f1,f2,f3,f4}; BOOL updated = [self updateUniformLocation:location withData:floats sizeOfData:sizeof(floats)]; @@ -320,7 +354,7 @@ -(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1 f2:(GLfloat)f glUniform4f( (GLint)location, f1, f2, f3,f4); } --(void) setUniformLocation:(NSUInteger)location with2fv:(GLfloat*)floats count:(NSUInteger)numberOfArrays +-(void) setUniformLocation:(GLint)location with2fv:(GLfloat*)floats count:(NSUInteger)numberOfArrays { BOOL updated = [self updateUniformLocation:location withData:floats sizeOfData:sizeof(float)*2*numberOfArrays]; @@ -328,7 +362,7 @@ -(void) setUniformLocation:(NSUInteger)location with2fv:(GLfloat*)floats count:( glUniform2fv( (GLint)location, (GLsizei)numberOfArrays, floats ); } --(void) setUniformLocation:(NSUInteger)location with3fv:(GLfloat*)floats count:(NSUInteger)numberOfArrays +-(void) setUniformLocation:(GLint)location with3fv:(GLfloat*)floats count:(NSUInteger)numberOfArrays { BOOL updated = [self updateUniformLocation:location withData:floats sizeOfData:sizeof(float)*3*numberOfArrays]; @@ -336,7 +370,7 @@ -(void) setUniformLocation:(NSUInteger)location with3fv:(GLfloat*)floats count:( glUniform3fv( (GLint)location, (GLsizei)numberOfArrays, floats ); } --(void) setUniformLocation:(NSUInteger)location with4fv:(GLvoid*)floats count:(NSUInteger)numberOfArrays +-(void) setUniformLocation:(GLint)location with4fv:(GLvoid*)floats count:(NSUInteger)numberOfArrays { BOOL updated = [self updateUniformLocation:location withData:floats sizeOfData:sizeof(float)*4*numberOfArrays]; @@ -345,7 +379,7 @@ -(void) setUniformLocation:(NSUInteger)location with4fv:(GLvoid*)floats count:(N } --(void) setUniformLocation:(NSUInteger)location withMatrix4fv:(GLvoid*)matrixArray count:(NSUInteger)numberOfMatrices +-(void) setUniformLocation:(GLint)location withMatrix4fv:(GLvoid*)matrixArray count:(NSUInteger)numberOfMatrices { BOOL updated = [self updateUniformLocation:location withData:matrixArray sizeOfData:sizeof(float)*16*numberOfMatrices]; @@ -353,7 +387,7 @@ -(void) setUniformLocation:(NSUInteger)location withMatrix4fv:(GLvoid*)matrixArr glUniformMatrix4fv( (GLint)location, (GLsizei)numberOfMatrices, GL_FALSE, matrixArray); } --(void) setUniformForModelViewProjectionMatrix +-(void) setUniformsForBuiltins { kmMat4 matrixP; kmMat4 matrixMV; @@ -364,7 +398,30 @@ -(void) setUniformForModelViewProjectionMatrix kmMat4Multiply(&matrixMVP, &matrixP, &matrixMV); + [self setUniformLocation:uniforms_[ kCCUniformPMatrix] withMatrix4fv: matrixP.mat count:1]; + [self setUniformLocation:uniforms_[ kCCUniformMVMatrix] withMatrix4fv: matrixMV.mat count:1]; [self setUniformLocation:uniforms_[kCCUniformMVPMatrix] withMatrix4fv:matrixMVP.mat count:1]; + + if(usesTime_){ + CCDirector *director = [CCDirector sharedDirector]; + // This doesn't give the most accurate global time value. + // Cocos2D doesn't store a high precision time value, so this will have to do. + // Getting Mach time per frame per shader using time could be extremely expensive. + ccTime time = director.totalFrames*director.animationInterval; + + [self setUniformLocation:uniforms_[kCCUniformTime] withF1:time/10.0 f2:time f3:time*2 f4:time*4]; + [self setUniformLocation:uniforms_[kCCUniformSinTime] withF1:sinf(time/8.0) f2:sinf(time/4.0) f3:sinf(time/2.0) f4:sinf(time)]; + [self setUniformLocation:uniforms_[kCCUniformCosTime] withF1:cosf(time/8.0) f2:cosf(time/4.0) f3:cosf(time/2.0) f4:cosf(time)]; + } + + if(uniforms_[kCCUniformRandom01] != -1){ + [self setUniformLocation:uniforms_[kCCUniformRandom01] withF1:CCRANDOM_0_1() f2:CCRANDOM_0_1() f3:CCRANDOM_0_1() f4:CCRANDOM_0_1()]; + } +} + +-(void)setUniformForModelViewProjectionMatrix; +{ + [self setUniformsForBuiltins]; } @@ -376,13 +433,13 @@ - (void)dealloc // there is no need to delete the shaders. They should have been already deleted. NSAssert( vertShader_ == 0, @"Vertex Shaders should have been already deleted"); - NSAssert( fragShader_ == 0, @"Vertex Shaders should have been already deleted"); + NSAssert( fragShader_ == 0, @"Fragment Shaders should have been already deleted"); + + if (program_) + ccGLDeleteProgram(program_); - if (program_) - ccGLDeleteProgram(program_); - tHashUniformEntry *current_element, *tmp; - + // Purge uniform hash HASH_ITER(hh, hashForUniforms_, current_element, tmp) { HASH_DEL(hashForUniforms_, current_element); @@ -390,6 +447,6 @@ - (void)dealloc free(current_element); } - [super dealloc]; + [super dealloc]; } @end diff --git a/vendor/Pods/cocos2d/cocos2d/CCGrid.m b/vendor/Pods/cocos2d/cocos2d/CCGrid.m index cab291a..df67c65 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCGrid.m +++ b/vendor/Pods/cocos2d/cocos2d/CCGrid.m @@ -280,7 +280,7 @@ -(void)blit ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_TexCoords ); [shaderProgram_ use]; - [shaderProgram_ setUniformForModelViewProjectionMatrix]; + [shaderProgram_ setUniformsForBuiltins]; // // Attributes @@ -431,7 +431,7 @@ -(void)blit NSInteger n = gridSize_.x * gridSize_.y; [shaderProgram_ use]; - [shaderProgram_ setUniformForModelViewProjectionMatrix]; + [shaderProgram_ setUniformsForBuiltins]; // diff --git a/vendor/Pods/cocos2d/cocos2d/CCLabelBMFont.h b/vendor/Pods/cocos2d/cocos2d/CCLabelBMFont.h index fc07359..4d15574 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCLabelBMFont.h +++ b/vendor/Pods/cocos2d/cocos2d/CCLabelBMFont.h @@ -40,8 +40,6 @@ enum { kCCLabelAutomaticWidth = -1, }; -struct _KerningHashElement; - /** @struct ccBMFontDef BMFont definition */ @@ -73,6 +71,22 @@ typedef struct _BMFontPadding { int bottom; } ccBMFontPadding; +#pragma mark - Hash Element +typedef struct _FontDefHashElement +{ + NSUInteger key; // key. Font Unicode value + ccBMFontDef fontDef; // font definition + UT_hash_handle hh; +} tCCFontDefHashElement; + +// Equal function for targetSet. +typedef struct _KerningHashElement +{ + int key; // key for the hash. 16-bit for 1st element, 16-bit for 2nd element + int amount; + UT_hash_handle hh; +} tCCKerningHashElement; +#pragma mark - /** CCBMFontConfiguration has parsed configuration of the the .fnt file @since v0.8 @@ -81,21 +95,21 @@ typedef struct _BMFontPadding { { // atlas name NSString *atlasName_; - + // XXX: Creating a public interface so that the bitmapFontArray[] is accesible @public - + // BMFont definitions - struct _FontDefHashElement *fontDefDictionary_; - + tCCFontDefHashElement *fontDefDictionary_; + // FNTConfig: Common Height. Should be signed (issue #1343) NSInteger commonHeight_; - + // Padding ccBMFontPadding padding_; - + // values for kerning - struct _KerningHashElement *kerningDictionary_; + tCCKerningHashElement *kerningDictionary_; } // atlasName @@ -109,7 +123,7 @@ typedef struct _BMFontPadding { /** CCLabelBMFont is a subclass of CCSpriteBatchNode - + Features: - Treats each character like a CCSprite. This means that each individual character can be: - rotated @@ -120,22 +134,22 @@ typedef struct _BMFontPadding { - It can be used as part of a menu item. - anchorPoint can be used to align the "label" - Supports AngelCode text format - + Limitations: - All inner characters are using an anchorPoint of (0.5f, 0.5f) and it is not recommend to change it because it might affect the rendering - + CCLabelBMFont implements the protocol CCLabelProtocol, like CCLabel and CCLabelAtlas. CCLabelBMFont has the flexibility of CCLabel, the speed of CCLabelAtlas and all the features of CCSprite. If in doubt, use CCLabelBMFont instead of CCLabelAtlas / CCLabel. - + Supported editors: - http://glyphdesigner.71squared.com/ - http://www.bmglyph.com/ - http://www.n4te.com/hiero/hiero.jnlp - http://slick.cokeandcode.com/demos/hiero.jnlp - http://www.angelcode.com/products/bmfont/ - + @since v0.8 */ @@ -146,16 +160,16 @@ typedef struct _BMFontPadding { // name of fntFile NSString *fntFile_; - + // initial string without line breaks NSString *initialString_; // max width until a line break is added float width_; // alignment of all lines CCTextAlignment alignment_; - + CCBMFontConfiguration *configuration_; - + // texture RGBA GLubyte opacity_; ccColor3B color_; diff --git a/vendor/Pods/cocos2d/cocos2d/CCLabelBMFont.m b/vendor/Pods/cocos2d/cocos2d/CCLabelBMFont.m index 371f70c..7319f40 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCLabelBMFont.m +++ b/vendor/Pods/cocos2d/cocos2d/CCLabelBMFont.m @@ -52,17 +52,17 @@ CCBMFontConfiguration* FNTConfigLoadFile( NSString *fntFile) { CCBMFontConfiguration *ret = nil; - + if( configurations == nil ) configurations = [[NSMutableDictionary dictionaryWithCapacity:3] retain]; - + ret = [configurations objectForKey:fntFile]; if( ret == nil ) { ret = [CCBMFontConfiguration configurationWithFNTFile:fntFile]; if( ret ) [configurations setObject:ret forKey:fntFile]; } - + return ret; } @@ -71,28 +71,9 @@ void FNTConfigRemoveCache( void ) [configurations removeAllObjects]; } -#pragma mark - Hash Element - -// Equal function for targetSet. -typedef struct _KerningHashElement -{ - int key; // key for the hash. 16-bit for 1st element, 16-bit for 2nd element - int amount; - UT_hash_handle hh; -} tKerningHashElement; - - #pragma mark - #pragma mark BitmapFontConfiguration -typedef struct _FontDefHashElement -{ - NSUInteger key; // key. Font Unicode value - ccBMFontDef fontDef; // font definition - UT_hash_handle hh; -} tFontDefHashElement; - - @interface CCBMFontConfiguration () -(BOOL) parseConfigFile:(NSString*)controlFile; -(void) parseCharacterDefinition:(NSString*)line charDef:(ccBMFontDef*)characterDefinition; @@ -118,10 +99,10 @@ +(id) configurationWithFNTFile:(NSString*)FNTfile -(id) initWithFNTfile:(NSString*)fntFile { if((self=[super init])) { - + kerningDictionary_ = NULL; fontDefDictionary_ = NULL; - + if( ! [self parseConfigFile:fntFile] ) { [self release]; return nil; @@ -150,7 +131,7 @@ - (NSString*) description -(void) purgeFontDefDictionary { - tFontDefHashElement *current, *tmp; + tCCFontDefHashElement *current, *tmp; HASH_ITER(hh, fontDefDictionary_, current, tmp) { HASH_DEL(fontDefDictionary_, current); @@ -160,8 +141,8 @@ -(void) purgeFontDefDictionary -(void) purgeKerningDictionary { - tKerningHashElement *current; - + tCCKerningHashElement *current; + while(kerningDictionary_) { current = kerningDictionary_; HASH_DEL(kerningDictionary_,current); @@ -174,21 +155,21 @@ - (BOOL)parseConfigFile:(NSString*)fntFile NSString *fullpath = [[CCFileUtils sharedFileUtils] fullPathFromRelativePath:fntFile]; NSError *error; NSString *contents = [NSString stringWithContentsOfFile:fullpath encoding:NSUTF8StringEncoding error:&error]; - + if( ! contents ) { NSLog(@"cocos2d: Error parsing FNTfile %@: %@", fntFile, error); return NO; } - + // Move all lines in the string, which are denoted by \n, into an array NSArray *lines = [[NSArray alloc] initWithArray:[contents componentsSeparatedByString:@"\n"]]; - + // Create an enumerator which we can use to move through the lines read from the control file NSEnumerator *nse = [lines objectEnumerator]; - + // Create a holder for each line we are going to work with NSString *line; - + // Loop through all the lines in the lines array processing each one while( (line = [nse nextObject]) ) { // parse spacing / padding @@ -209,16 +190,16 @@ - (BOOL)parseConfigFile:(NSString*)fntFile } else if([line hasPrefix:@"char"]) { // Parse the current line and create a new CharDef - tFontDefHashElement *element = malloc( sizeof(*element) ); + tCCFontDefHashElement *element = malloc( sizeof(*element) ); [self parseCharacterDefinition:line charDef:&element->fontDef]; element->key = element->fontDef.charID; HASH_ADD_INT(fontDefDictionary_, key, element); } -// else if([line hasPrefix:@"kernings count"]) { -// [self parseKerningCapacity:line]; -// } + // else if([line hasPrefix:@"kernings count"]) { + // [self parseKerningCapacity:line]; + // } else if([line hasPrefix:@"kerning first"]) { [self parseKerningEntry:line]; } @@ -232,30 +213,30 @@ - (BOOL)parseConfigFile:(NSString*)fntFile -(void) parseImageFileName:(NSString*)line fntFile:(NSString*)fntFile { NSString *propertyValue = nil; - + // Break the values for this line up using = NSArray *values = [line componentsSeparatedByString:@"="]; - + // Get the enumerator for the array of components which has been created NSEnumerator *nse = [values objectEnumerator]; - + // We need to move past the first entry in the array before we start assigning values [nse nextObject]; - + // page ID. Sanity check propertyValue = [nse nextObject]; NSAssert( [propertyValue intValue] == 0, @"XXX: LabelBMFont only supports 1 page"); - + // file propertyValue = [nse nextObject]; NSArray *array = [propertyValue componentsSeparatedByString:@"\""]; propertyValue = [array objectAtIndex:1]; NSAssert(propertyValue,@"LabelBMFont file could not be found"); - + // Supports subdirectories NSString *dir = [fntFile stringByDeletingLastPathComponent]; atlasName_ = [dir stringByAppendingPathComponent:propertyValue]; - + [atlasName_ retain]; } @@ -269,62 +250,62 @@ -(void) parseInfoArguments:(NSString*)line NSArray *values = [line componentsSeparatedByString:@"="]; NSEnumerator *nse = [values objectEnumerator]; NSString *propertyValue = nil; - + // We need to move past the first entry in the array before we start assigning values [nse nextObject]; - + // face (ignore) [nse nextObject]; - + // size (ignore) [nse nextObject]; - + // bold (ignore) [nse nextObject]; - + // italic (ignore) [nse nextObject]; - + // charset (ignore) [nse nextObject]; - + // unicode (ignore) [nse nextObject]; - + // strechH (ignore) [nse nextObject]; - + // smooth (ignore) [nse nextObject]; - + // aa (ignore) [nse nextObject]; - + // padding (ignore) propertyValue = [nse nextObject]; { - + NSArray *paddingValues = [propertyValue componentsSeparatedByString:@","]; NSEnumerator *paddingEnum = [paddingValues objectEnumerator]; // padding top propertyValue = [paddingEnum nextObject]; padding_.top = [propertyValue intValue]; - + // padding right propertyValue = [paddingEnum nextObject]; padding_.right = [propertyValue intValue]; - + // padding bottom propertyValue = [paddingEnum nextObject]; padding_.bottom = [propertyValue intValue]; - + // padding left propertyValue = [paddingEnum nextObject]; padding_.left = [propertyValue intValue]; - + CCLOG(@"cocos2d: padding: %d,%d,%d,%d", padding_.left, padding_.top, padding_.right, padding_.bottom); } - + // spacing (ignore) [nse nextObject]; } @@ -338,30 +319,30 @@ -(void) parseCommonArguments:(NSString*)line NSArray *values = [line componentsSeparatedByString:@"="]; NSEnumerator *nse = [values objectEnumerator]; NSString *propertyValue = nil; - + // We need to move past the first entry in the array before we start assigning values [nse nextObject]; - + // Character ID propertyValue = [nse nextObject]; commonHeight_ = [propertyValue intValue]; - + // base (ignore) [nse nextObject]; - - + + // scaleW. sanity check propertyValue = [nse nextObject]; NSAssert( [propertyValue intValue] <= [[CCConfiguration sharedConfiguration] maxTextureSize], @"CCLabelBMFont: page can't be larger than supported"); - + // scaleH. sanity check propertyValue = [nse nextObject]; NSAssert( [propertyValue intValue] <= [[CCConfiguration sharedConfiguration] maxTextureSize], @"CCLabelBMFont: page can't be larger than supported"); - + // pages. sanity check propertyValue = [nse nextObject]; NSAssert( [propertyValue intValue] == 1, @"CCBitfontAtlas: only supports 1 page"); - + // packed (ignore) What does this mean ?? } - (void)parseCharacterDefinition:(NSString*)line charDef:(ccBMFontDef*)characterDefinition @@ -370,15 +351,15 @@ - (void)parseCharacterDefinition:(NSString*)line charDef:(ccBMFontDef*)character NSArray *values = [line componentsSeparatedByString:@"="]; NSEnumerator *nse = [values objectEnumerator]; NSString *propertyValue; - + // We need to move past the first entry in the array before we start assigning values [nse nextObject]; - + // Character ID propertyValue = [nse nextObject]; propertyValue = [propertyValue substringToIndex: [propertyValue rangeOfString: @" "].location]; characterDefinition->charID = [propertyValue intValue]; - + // Character x propertyValue = [nse nextObject]; characterDefinition->rect.origin.x = [propertyValue intValue]; @@ -407,23 +388,23 @@ -(void) parseKerningEntry:(NSString*) line NSArray *values = [line componentsSeparatedByString:@"="]; NSEnumerator *nse = [values objectEnumerator]; NSString *propertyValue; - + // We need to move past the first entry in the array before we start assigning values [nse nextObject]; - + // first propertyValue = [nse nextObject]; int first = [propertyValue intValue]; - + // second propertyValue = [nse nextObject]; int second = [propertyValue intValue]; - + // second propertyValue = [nse nextObject]; int amount = [propertyValue intValue]; - - tKerningHashElement *element = calloc( sizeof( *element ), 1 ); + + tCCKerningHashElement *element = calloc( sizeof( *element ), 1 ); element->amount = amount; element->key = (first<<16) | (second&0xffff); HASH_ADD_INT(kerningDictionary_,key, element); @@ -498,25 +479,25 @@ -(id) initWithString:(NSString*)theString fntFile:(NSString*)fntFile width:(floa NSAssert( (theString && fntFile) || (theString==nil && fntFile==nil), @"Invalid params for CCLabelBMFont"); CCTexture2D *texture = nil; - + if( fntFile ) { CCBMFontConfiguration *newConf = FNTConfigLoadFile(fntFile); NSAssert( newConf, @"CCLabelBMFont: Impossible to create font. Please check file: '%@'", fntFile ); - + configuration_ = [newConf retain]; - + fntFile_ = [fntFile retain]; - + texture = [[CCTextureCache sharedTextureCache] addImage:configuration_.atlasName]; - + } else texture = [[[CCTexture2D alloc] init] autorelease]; - - + + if( (self=[super initWithTexture:texture capacity:[theString length]]) ) { width_ = width; alignment_ = alignment; - + opacity_ = 255; color_ = ccWHITE; @@ -525,12 +506,12 @@ -(id) initWithString:(NSString*)theString fntFile:(NSString*)fntFile width:(floa opacityModifyRGB_ = [[textureAtlas_ texture] hasPremultipliedAlpha]; anchorPoint_ = ccp(0.5f, 0.5f); - + imageOffset_ = offset; - + [self setString:theString updateLabel:YES]; } - + return self; } @@ -540,7 +521,7 @@ -(void) dealloc [initialString_ release]; [configuration_ release]; [fntFile_ release]; - + [super dealloc]; } @@ -693,14 +674,14 @@ -(int) kerningAmountForFirst:(unichar)first second:(unichar)second { int ret = 0; unsigned int key = (first<<16) | (second & 0xffff); - + if( configuration_->kerningDictionary_ ) { - tKerningHashElement *element = NULL; + tCCKerningHashElement *element = NULL; HASH_FIND_INT(configuration_->kerningDictionary_, &key, element); if(element) ret = element->amount; } - + return ret; } @@ -710,18 +691,18 @@ -(void) createFontChars NSInteger nextFontPositionY = 0; unichar prev = -1; NSInteger kerningAmount = 0; - + CGSize tmpSize = CGSizeZero; - + NSInteger longestLine = 0; NSUInteger totalHeight = 0; - + NSUInteger quantityOfLines = 1; - + NSUInteger stringLen = [string_ length]; if( ! stringLen ) return; - + // quantity of lines NEEDS to be calculated before parsing the lines, // since the Y position needs to be calcualted before hand for(NSUInteger i=0; i < stringLen-1;i++) { @@ -729,39 +710,42 @@ -(void) createFontChars if( c=='\n') quantityOfLines++; } - + totalHeight = configuration_->commonHeight_ * quantityOfLines; nextFontPositionY = -(configuration_->commonHeight_ - configuration_->commonHeight_*quantityOfLines); - + for(NSUInteger i = 0; icommonHeight_; continue; } - + kerningAmount = [self kerningAmountForFirst:prev second:c]; - + - tFontDefHashElement *element = NULL; + tCCFontDefHashElement *element = NULL; // unichar is a short, and an int is needed on HASH_FIND_INT NSUInteger key = (NSUInteger)c; HASH_FIND_INT(configuration_->fontDefDictionary_ , &key, element); - NSAssert(element, @"FontDefinition could not be found!"); - + if( ! element ) { + CCLOGWARN(@"cocos2d: LabelBMFont: characer not found %c", c); + continue; + } + ccBMFontDef fontDef = element->fontDef; - + CGRect rect = fontDef.rect; rect = CC_RECT_PIXELS_TO_POINTS(rect); rect.origin.x += imageOffset_.x; rect.origin.y += imageOffset_.y; - + CCSprite *fontChar; - + fontChar = (CCSprite*) [self getChildByTag:i]; if( ! fontChar ) { fontChar = [[CCSprite alloc] initWithTexture:textureAtlas_.texture rect:rect]; @@ -771,12 +755,12 @@ -(void) createFontChars else { // reusing fonts [fontChar setTextureRect:rect rotated:NO untrimmedSize:rect.size]; - + // restore to default in case they were modified fontChar.visible = YES; fontChar.opacity = 255; } - + // See issue 1343. cast( signed short + unsigned integer ) == unsigned integer (sign is lost!) NSInteger yOffset = configuration_->commonHeight_ - fontDef.yOffset; CGPoint fontPos = ccp( (CGFloat)nextFontPositionX + fontDef.xOffset + fontDef.rect.size.width*0.5f + kerningAmount, @@ -786,24 +770,24 @@ -(void) createFontChars // update kerning nextFontPositionX += fontDef.xAdvance + kerningAmount; prev = c; - + // Apply label properties [fontChar setOpacityModifyRGB:opacityModifyRGB_]; // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on [fontChar setColor:color_]; - + // only apply opacity if it is different than 255 ) // to prevent modifying the color too (issue #610) if( opacity_ != 255 ) [fontChar setOpacity: opacity_]; - + if (longestLine < nextFontPositionX) longestLine = nextFontPositionX; } - + tmpSize.width = longestLine; tmpSize.height = totalHeight; - + [self setContentSize:CC_SIZE_PIXELS_TO_POINTS(tmpSize)]; } @@ -848,7 +832,7 @@ - (void) setString:(NSString*) newString updateLabel:(BOOL)update -(void) setColor:(ccColor3B)color { color_ = color; - + CCSprite *child; CCARRAY_FOREACH(children_, child) [child setColor:color_]; @@ -857,7 +841,7 @@ -(void) setColor:(ccColor3B)color -(void) setOpacity:(GLubyte)opacity { opacity_ = opacity; - + id child; CCARRAY_FOREACH(children_, child) [child setOpacity:opacity_]; @@ -865,7 +849,7 @@ -(void) setOpacity:(GLubyte)opacity -(void) setOpacityModifyRGB:(BOOL)modify { opacityModifyRGB_ = modify; - + id child; CCARRAY_FOREACH(children_, child) [child setOpacityModifyRGB:modify]; @@ -910,7 +894,7 @@ - (void) setFntFile:(NSString*) fntFile [configuration_ release]; configuration_ = [newConf retain]; - + [self setTexture:[[CCTextureCache sharedTextureCache] addImage:configuration_.atlasName]]; [self createFontChars]; } @@ -926,7 +910,7 @@ - (NSString*) fntFile -(void) draw { [super draw]; - + CGSize s = [self contentSize]; CGPoint vertices[4]={ ccp(0,0),ccp(s.width,0), diff --git a/vendor/Pods/cocos2d/cocos2d/CCLabelTTF.h b/vendor/Pods/cocos2d/cocos2d/CCLabelTTF.h index 46a047b..8e6d5a9 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCLabelTTF.h +++ b/vendor/Pods/cocos2d/cocos2d/CCLabelTTF.h @@ -69,7 +69,7 @@ - Mac: Only NSLineBreakByWordWrapping is supported. @since v1.0 */ -+ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size; ++ (id) labelWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment; /** creates a CCLabelTTF from a fontname, horizontal alignment, dimension in points, line break mode, and font size in points. Supported lineBreakModes: @@ -77,7 +77,7 @@ - Mac: Only NSLineBreakByWordWrapping is supported. @since v1.0 */ -+ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size; ++ (id) labelWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment lineBreakMode:(CCLineBreakMode)lineBreakMode; /** creates a CCLabelTTF from a fontname, horizontal aligment, vertical alignment, dimension in points, line break mode, and font size in points. Supported lineBreakModes: @@ -85,21 +85,21 @@ - Mac: Only NSLineBreakByWordWrapping is supported. @since v1.0 */ -+ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment)vertAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size; ++ (id) labelWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment)vertAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode ; /** creates a CCLabel from a fontname, alignment, dimension in points and font size in points*/ -+ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment)vertAlignment fontName:(NSString*)name fontSize:(CGFloat)size; ++ (id) labelWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment)vertAlignment; /** initializes the CCLabelTTF with a font name and font size in points */ -- (id) initWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size; +- (id) initWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size; /** initializes the CCLabelTTF with a font name, horizonal alignment, dimension in points, and font size in points. Default verticalAlignment: kCCVerticalTextAlignmentTop Default lineBreakMode: CCLineBreakModeWordWrap @since v1.0 */ -- (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size; +- (id) initWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment; /** initializes the CCLabelTTF with a font name, horizontal alignment, dimension in points, line break mode and font size in points. Default verticalAlignment: kCCVerticalTextAlignmentTop @@ -109,12 +109,12 @@ - Mac: Only NSLineBreakByWordWrapping is supported. @since v1.0 */ -- (id) initWithString:(NSString*)str dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size; +- (id) initWithString:(NSString*)str fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment lineBreakMode:(CCLineBreakMode)lineBreakMode; /** initializes the CCLabelTTF with a font name, horiozntal alignment, vertical alignment, dimension in points and font size in points. Default lineBreakMode: CCLineBreakModeWordWrap */ -- (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment)vertAlignment fontName:(NSString*)name fontSize:(CGFloat)size; +- (id) initWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment)vertAlignment; /** initializes the CCLabelTTF with a font name, horizontal alignment, vertical aligment, dimension in points, line break mode and font size in points. Supported lineBreakModes: @@ -122,7 +122,7 @@ - Mac: Only NSLineBreakByWordWrapping is supported. @since v2.0 */ -- (id) initWithString:(NSString*)str dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment)vAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size; +- (id) initWithString:(NSString*)str fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment)vAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode ; /** changes the string to render * @warning Changing the string is as expensive as creating a new CCLabelTTF. To obtain better performance use CCLabelAtlas or CCLabelBMFont. diff --git a/vendor/Pods/cocos2d/cocos2d/CCLabelTTF.m b/vendor/Pods/cocos2d/cocos2d/CCLabelTTF.m index 6eec6d8..921a7de 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCLabelTTF.m +++ b/vendor/Pods/cocos2d/cocos2d/CCLabelTTF.m @@ -45,6 +45,7 @@ @interface CCLabelTTF () -(void) updateTexture; +- (NSString*) getFontName:(NSString*)fontName; @end @implementation CCLabelTTF @@ -56,27 +57,27 @@ + (id) labelWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFl } // hAlignment -+ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size ++ (id) labelWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment { - return [[[self alloc] initWithString: string dimensions:dimensions hAlignment:alignment vAlignment:kCCVerticalTextAlignmentTop lineBreakMode:kCCLineBreakModeWordWrap fontName:name fontSize:size]autorelease]; + return [[[self alloc] initWithString:string fontName:name fontSize:size dimensions:dimensions hAlignment:alignment vAlignment:kCCVerticalTextAlignmentTop lineBreakMode:kCCLineBreakModeWordWrap]autorelease]; } // hAlignment, vAlignment -+ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment) vertAlignment fontName:(NSString*)name fontSize:(CGFloat)size ++ (id) labelWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment) vertAlignment { - return [[[self alloc] initWithString: string dimensions:dimensions hAlignment:alignment vAlignment:vertAlignment fontName:name fontSize:size]autorelease]; + return [[[self alloc] initWithString:string fontName:name fontSize:size dimensions:dimensions hAlignment:alignment vAlignment:vertAlignment]autorelease]; } // hAlignment, lineBreakMode -+ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size; ++ (id) labelWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment lineBreakMode:(CCLineBreakMode)lineBreakMode { - return [[[self alloc] initWithString: string dimensions:dimensions hAlignment:alignment vAlignment:kCCVerticalTextAlignmentTop lineBreakMode:lineBreakMode fontName:name fontSize:size]autorelease]; + return [[[self alloc] initWithString:string fontName:name fontSize:size dimensions:dimensions hAlignment:alignment vAlignment:kCCVerticalTextAlignmentTop lineBreakMode:lineBreakMode]autorelease]; } // hAlignment, vAlignment, lineBreakMode -+ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment) vertAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size; ++ (id) labelWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment) vertAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode { - return [[[self alloc] initWithString: string dimensions:dimensions hAlignment:alignment vAlignment:vertAlignment lineBreakMode:lineBreakMode fontName:name fontSize:size]autorelease]; + return [[[self alloc] initWithString:string fontName:name fontSize:size dimensions:dimensions hAlignment:alignment vAlignment:vertAlignment lineBreakMode:lineBreakMode]autorelease]; } - (id) init @@ -86,29 +87,29 @@ - (id) init - (id) initWithString:(NSString*)str fontName:(NSString*)name fontSize:(CGFloat)size { - return [self initWithString:str dimensions:CGSizeZero hAlignment:kCCTextAlignmentLeft vAlignment:kCCVerticalTextAlignmentTop lineBreakMode:kCCLineBreakModeWordWrap fontName:name fontSize:size]; + return [self initWithString:str fontName:name fontSize:size dimensions:CGSizeZero hAlignment:kCCTextAlignmentLeft vAlignment:kCCVerticalTextAlignmentTop lineBreakMode:kCCLineBreakModeWordWrap]; } // hAlignment -- (id) initWithString:(NSString*)str dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size +- (id) initWithString:(NSString*)str fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment { - return [self initWithString:str dimensions:dimensions hAlignment:alignment vAlignment:kCCVerticalTextAlignmentTop lineBreakMode:kCCLineBreakModeWordWrap fontName:name fontSize:size]; + return [self initWithString:str fontName:name fontSize:size dimensions:dimensions hAlignment:alignment vAlignment:kCCVerticalTextAlignmentTop lineBreakMode:kCCLineBreakModeWordWrap]; } // hAlignment, vAlignment -- (id) initWithString:(NSString*)str dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment) vertAlignment fontName:(NSString*)name fontSize:(CGFloat)size +- (id) initWithString:(NSString*)str fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment) vertAlignment { - return [self initWithString:str dimensions:dimensions hAlignment:alignment vAlignment:vertAlignment lineBreakMode:kCCLineBreakModeWordWrap fontName:name fontSize:size]; + return [self initWithString:str fontName:name fontSize:size dimensions:dimensions hAlignment:alignment vAlignment:vertAlignment lineBreakMode:kCCLineBreakModeWordWrap]; } // hAlignment, lineBreakMode -- (id) initWithString:(NSString*)str dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size +- (id) initWithString:(NSString*)str fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment lineBreakMode:(CCLineBreakMode)lineBreakMode { - return [self initWithString:str dimensions:dimensions hAlignment:alignment vAlignment:kCCVerticalTextAlignmentTop lineBreakMode:lineBreakMode fontName:name fontSize:size]; + return [self initWithString:str fontName:name fontSize:size dimensions:dimensions hAlignment:alignment vAlignment:kCCVerticalTextAlignmentTop lineBreakMode:lineBreakMode]; } // hAlignment, vAligment, lineBreakMode -- (id) initWithString:(NSString*)str dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment) vertAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size +- (id) initWithString:(NSString*)str fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment) vertAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode { if( (self=[super init]) ) { @@ -118,7 +119,7 @@ - (id) initWithString:(NSString*)str dimensions:(CGSize)dimensions hAlignment:(C dimensions_ = dimensions; hAlignment_ = alignment; vAlignment_ = vertAlignment; - fontName_ = [name retain]; + fontName_ = [[self getFontName: name] copy]; fontSize_ = size; lineBreakMode_ = lineBreakMode; @@ -144,24 +145,32 @@ -(NSString*) string return string_; } +- (NSString*) getFontName:(NSString*)fontName +{ +#ifdef __CC_PLATFORM_MAC + // Custom .ttf file ? + if ([[fontName lowercaseString] hasSuffix:@".ttf"]) + { + // This is a file, register font with font manager + NSString* fontFile = [[CCFileUtils sharedFileUtils] fullPathFromRelativePath:fontName]; + NSURL* fontURL = [NSURL fileURLWithPath:fontFile]; + CTFontManagerRegisterFontsForURL((CFURLRef)fontURL, kCTFontManagerScopeProcess, NULL); + + return [[fontFile lastPathComponent] stringByDeletingPathExtension]; + } +#endif // + + return fontName; +} + - (void)setFontName:(NSString*)fontName { + fontName = [self getFontName:fontName]; + if( fontName.hash != fontName_.hash ) { [fontName_ release]; fontName_ = [fontName copy]; -#ifdef __CC_PLATFORM_MAC - if ([[fontName lowercaseString] hasSuffix:@".ttf"] || YES) - { - // This is a file, register font with font manager - NSString* fontFile = [[CCFileUtils sharedFileUtils] fullPathFromRelativePath:fontName]; - NSURL* fontURL = [NSURL fileURLWithPath:fontFile]; - CTFontManagerRegisterFontsForURL((CFURLRef)fontURL, kCTFontManagerScopeProcess, NULL); - NSString *newFontName = [[fontFile lastPathComponent] stringByDeletingPathExtension]; - - fontName_ = [newFontName copy]; - } -#endif // Force update if( string_ ) [self updateTexture]; @@ -266,12 +275,13 @@ - (void) updateTexture fontSize:fontSize_ * CC_CONTENT_SCALE_FACTOR()]; else tex = [[CCTexture2D alloc] initWithString:string_ + fontName:fontName_ + fontSize:fontSize_ * CC_CONTENT_SCALE_FACTOR() dimensions:CC_SIZE_POINTS_TO_PIXELS(dimensions_) hAlignment:hAlignment_ vAlignment:vAlignment_ lineBreakMode:lineBreakMode_ - fontName:fontName_ - fontSize:fontSize_ * CC_CONTENT_SCALE_FACTOR()]; + ]; #ifdef __CC_PLATFORM_IOS // iPad ? diff --git a/vendor/Pods/cocos2d/cocos2d/CCLayer.m b/vendor/Pods/cocos2d/cocos2d/CCLayer.m index ee30bdb..b71f6a0 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCLayer.m +++ b/vendor/Pods/cocos2d/cocos2d/CCLayer.m @@ -319,7 +319,7 @@ - (id) initWithColor:(ccColor4B)color width:(GLfloat)w height:(GLfloat) h if( (self=[super init]) ) { // default blend function - blendFunc_ = (ccBlendFunc) { GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }; + blendFunc_ = (ccBlendFunc) { CC_BLEND_SRC, CC_BLEND_DST }; color_.r = color.r; color_.g = color.g; diff --git a/vendor/Pods/cocos2d/cocos2d/CCMenu.h b/vendor/Pods/cocos2d/cocos2d/CCMenu.h index 72a51b3..0822345 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCMenu.h +++ b/vendor/Pods/cocos2d/cocos2d/CCMenu.h @@ -60,15 +60,15 @@ enum { /** whether or not the menu will receive events */ @property (nonatomic, readwrite) BOOL enabled; -/** creates a CCMenu with its items */ +/** creates a CCMenu with CCMenuItem objects */ + (id) menuWithItems: (CCMenuItem*) item, ... NS_REQUIRES_NIL_TERMINATION; +/** creates a CCMenu with CCMenuItem objects */ ++ (id) menuWithItems: (CCMenuItem*) firstItem vaList: (va_list) args; + /** creates a CCMenu with a NSArray of CCMenuItem objects */ + (id) menuWithArray:(NSArray*)arrayOfItems; -/** initializes a CCMenu with its items */ -- (id) initWithItems: (CCMenuItem*) item vaList: (va_list) args; - /** initializes a CCMenu with a NSArray of CCMenuItem objects */ - (id) initWithArray:(NSArray*)arrayOfItems; @@ -89,10 +89,12 @@ enum { /** align items in rows of columns */ -(void) alignItemsInColumns: (NSNumber *) columns, ... NS_REQUIRES_NIL_TERMINATION; -(void) alignItemsInColumns: (NSNumber *) columns vaList: (va_list) args; +-(void) alignItemsInColumnsWithArray:(NSArray*) arrayOfNumbers; /** align items in columns of rows */ -(void) alignItemsInRows: (NSNumber *) rows, ... NS_REQUIRES_NIL_TERMINATION; -(void) alignItemsInRows: (NSNumber *) rows vaList: (va_list) args; +-(void) alignItemsInRowsWithArray: (NSArray*) arrayOfNumbers; /** set event handler priority. By default it is: kCCMenuTouchPriority */ -(void) setHandlerPriority:(NSInteger)newPriority; diff --git a/vendor/Pods/cocos2d/cocos2d/CCMenu.m b/vendor/Pods/cocos2d/cocos2d/CCMenu.m index 5b1525b..25223fd 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCMenu.m +++ b/vendor/Pods/cocos2d/cocos2d/CCMenu.m @@ -59,18 +59,14 @@ +(id) menuWithItems: (CCMenuItem*) item, ... va_list args; va_start(args,item); - id s = [[[self alloc] initWithItems: item vaList:args] autorelease]; + id ret = [self menuWithItems:item vaList:args]; va_end(args); - return s; -} - --(id) init -{ - return [self initWithArray:nil]; + + return ret; } --(id) initWithItems: (CCMenuItem*) item vaList: (va_list) args ++(id) menuWithItems: (CCMenuItem*) item vaList: (va_list) args { NSMutableArray *array = nil; if( item ) { @@ -81,10 +77,16 @@ -(id) initWithItems: (CCMenuItem*) item vaList: (va_list) args i = va_arg(args, CCMenuItem*); } } + + return [[[self alloc] initWithArray:array] autorelease]; +} - return [self initWithArray:array]; +-(id) init +{ + return [self initWithArray:nil]; } + -(id) initWithArray:(NSArray *)arrayOfItems { if( (self=[super init]) ) { @@ -394,30 +396,37 @@ -(void) alignItemsInColumns: (NSNumber *) columns vaList: (va_list) args columns = va_arg(args, NSNumber*); } + [self alignItemsInColumnsWithArray:rows]; + + [rows release]; +} + +-(void) alignItemsInColumnsWithArray:(NSArray*) rows +{ int height = -5; NSUInteger row = 0, rowHeight = 0, columnsOccupied = 0, rowColumns; CCMenuItem *item; CCARRAY_FOREACH(children_, item){ NSAssert( row < [rows count], @"Too many menu items for the amount of rows/columns."); - + rowColumns = [(NSNumber *) [rows objectAtIndex:row] unsignedIntegerValue]; NSAssert( rowColumns, @"Can't have zero columns on a row"); - + rowHeight = fmaxf(rowHeight, item.contentSize.height); ++columnsOccupied; - + if(columnsOccupied >= rowColumns) { height += rowHeight + 5; - + columnsOccupied = 0; rowHeight = 0; ++row; } } NSAssert( !columnsOccupied, @"Too many rows/columns for available menu items." ); - + CGSize winSize = [[CCDirector sharedDirector] winSize]; - + row = 0; rowHeight = 0; rowColumns = 0; float w, x, y = height / 2; CCARRAY_FOREACH(children_, item) { @@ -426,26 +435,24 @@ -(void) alignItemsInColumns: (NSNumber *) columns vaList: (va_list) args w = winSize.width / (1 + rowColumns); x = w; } - + CGSize itemSize = item.contentSize; rowHeight = fmaxf(rowHeight, itemSize.height); [item setPosition:ccp(x - winSize.width / 2, y - itemSize.height / 2)]; - + x += w; ++columnsOccupied; - + if(columnsOccupied >= rowColumns) { y -= rowHeight + 5; - + columnsOccupied = 0; rowColumns = 0; rowHeight = 0; ++row; } } - - [rows release]; } -(void) alignItemsInRows: (NSNumber *) rows, ... @@ -467,28 +474,35 @@ -(void) alignItemsInRows: (NSNumber *) rows vaList: (va_list) args rows = va_arg(args, NSNumber*); } + [self alignItemsInRowsWithArray:columns]; + + [columns release]; +} + +-(void) alignItemsInRowsWithArray:(NSArray*) columns +{ NSMutableArray *columnWidths = [[NSMutableArray alloc] init]; NSMutableArray *columnHeights = [[NSMutableArray alloc] init]; - + int width = -10, columnHeight = -5; NSUInteger column = 0, columnWidth = 0, rowsOccupied = 0, columnRows; CCMenuItem *item; CCARRAY_FOREACH(children_, item){ NSAssert( column < [columns count], @"Too many menu items for the amount of rows/columns."); - + columnRows = [(NSNumber *) [columns objectAtIndex:column] unsignedIntegerValue]; NSAssert( columnRows, @"Can't have zero rows on a column"); - + CGSize itemSize = item.contentSize; columnWidth = fmaxf(columnWidth, itemSize.width); columnHeight += itemSize.height + 5; ++rowsOccupied; - + if(rowsOccupied >= columnRows) { [columnWidths addObject:[NSNumber numberWithUnsignedInteger:columnWidth]]; [columnHeights addObject:[NSNumber numberWithUnsignedInteger:columnHeight]]; width += columnWidth + 10; - + rowsOccupied = 0; columnWidth = 0; columnHeight = -5; @@ -496,29 +510,29 @@ -(void) alignItemsInRows: (NSNumber *) rows vaList: (va_list) args } } NSAssert( !rowsOccupied, @"Too many rows/columns for available menu items."); - + CGSize winSize = [[CCDirector sharedDirector] winSize]; - + column = 0; columnWidth = 0; columnRows = 0; float x = -width / 2, y; - + CCARRAY_FOREACH(children_, item){ if(columnRows == 0) { columnRows = [(NSNumber *) [columns objectAtIndex:column] unsignedIntegerValue]; y = ([(NSNumber *) [columnHeights objectAtIndex:column] intValue] + winSize.height) / 2; } - + CGSize itemSize = item.contentSize; columnWidth = fmaxf(columnWidth, itemSize.width); [item setPosition:ccp(x + [(NSNumber *) [columnWidths objectAtIndex:column] unsignedIntegerValue] / 2, y - winSize.height / 2)]; - + y -= itemSize.height + 10; ++rowsOccupied; - + if(rowsOccupied >= columnRows) { x += columnWidth + 5; - + rowsOccupied = 0; columnRows = 0; columnWidth = 0; @@ -526,7 +540,6 @@ -(void) alignItemsInRows: (NSNumber *) rows vaList: (va_list) args } } - [columns release]; [columnWidths release]; [columnHeights release]; } diff --git a/vendor/Pods/cocos2d/cocos2d/CCMenuItem.h b/vendor/Pods/cocos2d/cocos2d/CCMenuItem.h index 6336534..be48a73 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCMenuItem.h +++ b/vendor/Pods/cocos2d/cocos2d/CCMenuItem.h @@ -335,6 +335,9 @@ /** creates a menu item with a normal and selected image*/ +(id) itemWithNormalImage: (NSString*)value selectedImage:(NSString*) value2; +/** creates a menu item with a normal, selected and disabled image */ ++(id) itemWithNormalImage: (NSString*)value selectedImage:(NSString*) value2 disabledImage: (NSString*) value3; + /** creates a menu item with a normal and selected image with target/selector */ +(id) itemWithNormalImage: (NSString*)value selectedImage:(NSString*) value2 target:(id) r selector:(SEL) s; @@ -387,6 +390,7 @@ NSMutableArray* subItems_; GLubyte opacity_; ccColor3B color_; + CCMenuItem* currentItem_; } /** conforms with CCRGBAProtocol protocol */ @@ -403,15 +407,16 @@ /** creates a menu item from a list of items with a target/selector */ +(id) itemWithTarget:(id)target selector:(SEL)selector items:(CCMenuItem*) item, ... NS_REQUIRES_NIL_TERMINATION; ++(id) itemWithTarget:(id)target selector:(SEL)selector items:(CCMenuItem*) item vaList:(va_list)args; + +/** creates a menu item from a list of items. */ ++(id) itemWithItems:(NSArray*)arrayOfItems; /** creates a menu item from a list of items and executes the given block when the item is selected. The block will be "copied". */ +(id) itemWithItems:(NSArray*)arrayOfItems block:(void(^)(id sender))block; -/** initializes a menu item from a list of items with a target selector */ --(id) initWithTarget:(id)target selector:(SEL)selector items:(CCMenuItem*) item vaList:(va_list) args; - /** initializes a menu item from a list of items with a block. The block will be "copied". */ diff --git a/vendor/Pods/cocos2d/cocos2d/CCMenuItem.m b/vendor/Pods/cocos2d/cocos2d/CCMenuItem.m index 4a38b59..32023bb 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCMenuItem.m +++ b/vendor/Pods/cocos2d/cocos2d/CCMenuItem.m @@ -731,8 +731,15 @@ -(void) setDisabledSpriteFrame:(CCSpriteFrame *)frame // // MenuItemToggle // -@implementation CCMenuItemToggle +@interface CCMenuItemToggle () +/** + Reference to the current display item. + */ +@property (nonatomic, assign) CCMenuItem *currentItem; +@end +@implementation CCMenuItemToggle +@synthesize currentItem = currentItem_; @synthesize subItems = subItems_; @synthesize opacity = opacity_, color = color_; @@ -740,22 +747,17 @@ +(id) itemWithTarget: (id)t selector: (SEL)sel items: (CCMenuItem*) item, ... { va_list args; va_start(args, item); - - id s = [[[self alloc] initWithTarget: t selector:sel items: item vaList:args] autorelease]; - + + id s = [self itemWithTarget: t selector:sel items: item vaList:args]; + va_end(args); return s; } -+(id) itemWithItems:(NSArray*)arrayOfItems block:(void(^)(id))block -{ - return [[[self alloc] initWithItems:arrayOfItems block:block] autorelease]; -} - --(id) initWithTarget:(id)target selector:(SEL)selector items:(CCMenuItem*) item vaList: (va_list) args ++(id) itemWithTarget:(id)target selector:(SEL)selector items:(CCMenuItem*) item vaList: (va_list) args { NSMutableArray *array = [NSMutableArray arrayWithCapacity:2]; - + int z = 0; CCMenuItem *i = item; while(i) { @@ -763,14 +765,25 @@ -(id) initWithTarget:(id)target selector:(SEL)selector items:(CCMenuItem*) item [array addObject:i]; i = va_arg(args, CCMenuItem*); } - + // avoid retain cycle __block id t = target; - - return [self initWithItems:array block:^(id sender) { + + return [[[self alloc] initWithItems:array block:^(id sender) { [t performSelector:selector withObject:sender]; } - ]; + ] autorelease]; +} + + ++(id) itemWithItems:(NSArray*)arrayOfItems +{ + return [[[self alloc] initWithItems:arrayOfItems block:NULL] autorelease]; +} + ++(id) itemWithItems:(NSArray*)arrayOfItems block:(void(^)(id))block +{ + return [[[self alloc] initWithItems:arrayOfItems block:block] autorelease]; } -(id) initWithItems:(NSArray*)arrayOfItems block:(void(^)(id sender))block @@ -779,6 +792,7 @@ -(id) initWithItems:(NSArray*)arrayOfItems block:(void(^)(id sender))block self.subItems = [NSMutableArray arrayWithArray:arrayOfItems]; + currentItem_ = nil; selectedIndex_ = NSUIntegerMax; [self setSelectedIndex:0]; } @@ -796,12 +810,13 @@ -(void)setSelectedIndex:(NSUInteger)index { if( index != selectedIndex_ ) { selectedIndex_=index; - CCMenuItem *currentItem = (CCMenuItem*)[self getChildByTag:kCCCurrentItemTag]; - if( currentItem ) - [currentItem removeFromParentAndCleanup:NO]; + + if( currentItem_ ) + [currentItem_ removeFromParentAndCleanup:NO]; CCMenuItem *item = [subItems_ objectAtIndex:selectedIndex_]; - [self addChild:item z:0 tag:kCCCurrentItemTag]; + [self addChild:item z:0]; + self.currentItem = item; CGSize s = [item contentSize]; [self setContentSize: s]; diff --git a/vendor/Pods/cocos2d/cocos2d/CCNode.h b/vendor/Pods/cocos2d/cocos2d/CCNode.h index a4ab100..fb7bb15 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCNode.h +++ b/vendor/Pods/cocos2d/cocos2d/CCNode.h @@ -90,7 +90,7 @@ enum { Order in transformations with grid enabled -# The node will be translated (position) - -# The node will be rotated (rotation) + -# The node will be rotated (rotation, rotationX, rotationY) -# The node will be skewed (skewX, skewY) -# The node will be scaled (scale, scaleX, scaleY) -# The grid will capture the screen @@ -103,7 +103,7 @@ enum { @interface CCNode : NSObject { // rotation angle - float rotation_; + float rotationX_, rotationY_; // scaling factors float scaleX_, scaleY_; @@ -207,6 +207,11 @@ enum { @property(nonatomic,readwrite,assign) float skewY; /** The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW. */ @property(nonatomic,readwrite,assign) float rotation; +/** The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW. It only modifies the X rotation performing a horizontal rotational skew . */ +@property(nonatomic,readwrite,assign) float rotationX; +/** The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW. It only modifies the Y rotation performing a vertical rotational skew . */ +@property(nonatomic,readwrite,assign) float rotationY; + /** The scale factor of the node. 1.0 is the default scale factor. It modifies the X and Y scale at the same time. */ @property(nonatomic,readwrite,assign) float scale; /** The scale factor of the node. 1.0 is the default scale factor. It only modifies the X scale factor. */ @@ -454,7 +459,7 @@ enum { /** schedules the "update" method. It will use the order number 0. This method will be called every frame. Scheduled methods with a lower order value will be called before the ones that have a higher order value. - Only one "udpate" method could be scheduled per node. + Only one "update" method could be scheduled per node. @since v0.99.3 */ @@ -462,7 +467,7 @@ enum { /** schedules the "update" selector with a custom priority. This selector will be called every frame. Scheduled selectors with a lower priority will be called before the ones that have a higher value. - Only one "udpate" selector could be scheduled per node (You can't have 2 'update' selectors). + Only one "update" selector could be scheduled per node (You can't have 2 'update' selectors). @since v0.99.3 */ @@ -474,7 +479,6 @@ enum { */ -(void) unscheduleUpdate; - /** schedules a selector. The scheduled selector will be ticked every frame */ @@ -515,6 +519,9 @@ enum { */ -(void) pauseSchedulerAndActions; +/* Update will be called automatically every frame if "scheduleUpdate" is called, and the node is "live" + */ +-(void) update:(ccTime)delta; // transformation methods @@ -528,7 +535,7 @@ enum { @since v0.7.1 */ - (CGAffineTransform)parentToNodeTransform; -/** Retrusn the world affine transform matrix. The matrix is in Pixels. +/** Returns the world affine transform matrix. The matrix is in Pixels. @since v0.7.1 */ - (CGAffineTransform)nodeToWorldTransform; diff --git a/vendor/Pods/cocos2d/cocos2d/CCNode.m b/vendor/Pods/cocos2d/cocos2d/CCNode.m index a1da57f..010f3a6 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCNode.m +++ b/vendor/Pods/cocos2d/cocos2d/CCNode.m @@ -50,7 +50,7 @@ #if CC_NODE_RENDER_SUBPIXEL #define RENDER_IN_SUBPIXEL #else -#define RENDER_IN_SUBPIXEL (NSInteger) +#define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__)) #endif @@ -84,7 +84,7 @@ @implementation CCNode #pragma mark CCNode - Transform related properties -@synthesize rotation = rotation_, scaleX = scaleX_, scaleY = scaleY_; +@synthesize rotationX = rotationX_, rotationY = rotationY_, scaleX = scaleX_, scaleY = scaleY_; @synthesize position = position_; @synthesize anchorPoint = anchorPoint_, anchorPointInPoints = anchorPointInPoints_; @synthesize contentSize = contentSize_; @@ -105,7 +105,7 @@ -(id) init isRunning_ = NO; skewX_ = skewY_ = 0.0f; - rotation_ = 0.0f; + rotationX_ = rotationY_ = 0.0f; scaleX_ = scaleY_ = 1.0f; position_ = CGPointZero; contentSize_ = CGSizeZero; @@ -144,7 +144,7 @@ -(id) init orderOfArrival_ = 0; - glServerState_ = CC_GL_BLEND; + glServerState_ = 0; // set default scheduler and actionManager CCDirector *director = [CCDirector sharedDirector]; @@ -196,7 +196,25 @@ - (void) dealloc // getters synthesized, setters explicit -(void) setRotation: (float)newRotation { - rotation_ = newRotation; + rotationX_ = rotationY_ = newRotation; + isTransformDirty_ = isInverseDirty_ = YES; +} + +-(float) rotation +{ + NSAssert( rotationX_ == rotationY_, @"CCNode#rotation. RotationX != RotationY. Don't know which one to return"); + return rotationX_; +} + +-(void) setRotationX: (float)newX +{ + rotationX_ = newX; + isTransformDirty_ = isInverseDirty_ = YES; +} + +-(void) setRotationY: (float)newY +{ + rotationY_ = newY; isTransformDirty_ = isInverseDirty_ = YES; } @@ -750,6 +768,11 @@ - (void) pauseSchedulerAndActions [actionManager_ pauseTarget:self]; } +/* override me */ +-(void) update:(ccTime)delta +{ +} + #pragma mark CCNode Transform - (CGAffineTransform)nodeToParentTransform @@ -764,29 +787,35 @@ - (CGAffineTransform)nodeToParentTransform x += anchorPointInPoints_.x; y += anchorPointInPoints_.y; } - + // Rotation values - float c = 1, s = 0; - if( rotation_ ) { - float radians = -CC_DEGREES_TO_RADIANS(rotation_); - c = cosf(radians); - s = sinf(radians); + // Change rotation code to handle X and Y + // If we skew with the exact same value for both x and y then we're simply just rotating + float cx = 1, sx = 0, cy = 1, sy = 0; + if( rotationX_ || rotationY_ ) { + float radiansX = -CC_DEGREES_TO_RADIANS(rotationX_); + float radiansY = -CC_DEGREES_TO_RADIANS(rotationY_); + cx = cosf(radiansX); + sx = sinf(radiansX); + cy = cosf(radiansY); + sy = sinf(radiansY); } BOOL needsSkewMatrix = ( skewX_ || skewY_ ); - // optimization: // inline anchor point calculation if skew is not needed + // Adjusted transform calculation for rotational skew if( !needsSkewMatrix && !CGPointEqualToPoint(anchorPointInPoints_, CGPointZero) ) { - x += c * -anchorPointInPoints_.x * scaleX_ + -s * -anchorPointInPoints_.y * scaleY_; - y += s * -anchorPointInPoints_.x * scaleX_ + c * -anchorPointInPoints_.y * scaleY_; + x += cy * -anchorPointInPoints_.x * scaleX_ + -sx * -anchorPointInPoints_.y * scaleY_; + y += sy * -anchorPointInPoints_.x * scaleX_ + cx * -anchorPointInPoints_.y * scaleY_; } // Build Transform Matrix - transform_ = CGAffineTransformMake( c * scaleX_, s * scaleX_, - -s * scaleY_, c * scaleY_, + // Adjusted transfor m calculation for rotational skew + transform_ = CGAffineTransformMake( cy * scaleX_, sy * scaleX_, + -sx * scaleY_, cx * scaleY_, x, y ); // XXX: Try to inline skew diff --git a/vendor/Pods/cocos2d/cocos2d/CCParticleExamples.h b/vendor/Pods/cocos2d/cocos2d/CCParticleExamples.h index 313f86d..747c92a 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCParticleExamples.h +++ b/vendor/Pods/cocos2d/cocos2d/CCParticleExamples.h @@ -32,64 +32,86 @@ @interface CCParticleFire: CCParticleSystemQuad { } +// needed for BridgeSupport +-(id) init; @end //! A fireworks particle system @interface CCParticleFireworks : CCParticleSystemQuad { } +// needed for BridgeSupport +-(id) init; @end //! A sun particle system @interface CCParticleSun : CCParticleSystemQuad { } +// needed for BridgeSupport +-(id) init; @end //! A galaxy particle system @interface CCParticleGalaxy : CCParticleSystemQuad { } +// needed for BridgeSupport +-(id) init; @end //! A flower particle system @interface CCParticleFlower : CCParticleSystemQuad { } +// needed for BridgeSupport +-(id) init; @end //! A meteor particle system @interface CCParticleMeteor : CCParticleSystemQuad { } +// needed for BridgeSupport +-(id) init; @end //! An spiral particle system @interface CCParticleSpiral : CCParticleSystemQuad { } +// needed for BridgeSupport +-(id) init; @end //! An explosion particle system @interface CCParticleExplosion : CCParticleSystemQuad { } +// needed for BridgeSupport +-(id) init; @end //! An smoke particle system @interface CCParticleSmoke : CCParticleSystemQuad { } +// needed for BridgeSupport +-(id) init; @end //! An snow particle system @interface CCParticleSnow : CCParticleSystemQuad { } +// needed for BridgeSupport +-(id) init; @end //! A rain particle system @interface CCParticleRain : CCParticleSystemQuad { } +// needed for BridgeSupport +-(id) init; @end diff --git a/vendor/Pods/cocos2d/cocos2d/CCParticleSystem.h b/vendor/Pods/cocos2d/cocos2d/CCParticleSystem.h index 10050ff..be9b04c 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCParticleSystem.h +++ b/vendor/Pods/cocos2d/cocos2d/CCParticleSystem.h @@ -419,6 +419,12 @@ typedef void (*CC_UPDATE_PARTICLE_IMP)(id, SEL, tCCParticle*, CGPoint); */ +(id) particleWithFile:(NSString*)plistFile; +/* creates an void particle emitter with a maximun number of particles. + @since v2.1 +*/ ++(id) particleWithTotalParticles:(NSUInteger) numberOfParticles; + + /** initializes a CCParticleSystem from a plist file. This plist files can be creted manually or with Particle Designer: http://particledesigner.71squared.com/ diff --git a/vendor/Pods/cocos2d/cocos2d/CCParticleSystem.m b/vendor/Pods/cocos2d/cocos2d/CCParticleSystem.m index 3d5c38c..39bb2eb 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCParticleSystem.m +++ b/vendor/Pods/cocos2d/cocos2d/CCParticleSystem.m @@ -88,6 +88,11 @@ +(id) particleWithFile:(NSString*) plistFile return [[[self alloc] initWithFile:plistFile] autorelease]; } ++(id) particleWithTotalParticles:(NSUInteger) numberOfParticles +{ + return [[[self alloc] initWithTotalParticles:numberOfParticles] autorelease]; +} + -(id) init { return [self initWithTotalParticles:150]; } @@ -306,14 +311,14 @@ -(id) initWithTotalParticles:(NSUInteger) numberOfParticles autoRemoveOnFinish_ = NO; - // Optimization: compile udpateParticle method + // Optimization: compile updateParticle method updateParticleSel = @selector(updateQuadWithParticle:newPosition:); updateParticleImp = (CC_UPDATE_PARTICLE_IMP) [self methodForSelector:updateParticleSel]; //for batchNode transformSystemDirty_ = NO; - // udpate after action in run! + // update after action in run! [self scheduleUpdateWithPriority:1]; } return self; diff --git a/vendor/Pods/cocos2d/cocos2d/CCParticleSystemQuad.m b/vendor/Pods/cocos2d/cocos2d/CCParticleSystemQuad.m index b87504a..de01b17 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCParticleSystemQuad.m +++ b/vendor/Pods/cocos2d/cocos2d/CCParticleSystemQuad.m @@ -172,7 +172,7 @@ -(void) initVAO void (^createVAO)(void) = ^ { glGenVertexArrays(1, &VAOname_); - glBindVertexArray(VAOname_); + ccGLBindVAO(VAOname_); #define kQuadSize sizeof(quads_[0].bl) @@ -196,7 +196,8 @@ -(void) initVAO glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffersVBO_[1]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices_[0]) * totalParticles * 6, indices_, GL_STATIC_DRAW); - glBindVertexArray(0); + // Must unbind the VAO before changing the element buffer. + ccGLBindVAO(0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -423,12 +424,9 @@ -(void) draw NSAssert( particleIdx == particleCount, @"Abnormal error in particle quad"); - glBindVertexArray( VAOname_ ); - + ccGLBindVAO( VAOname_ ); glDrawElements(GL_TRIANGLES, (GLsizei) particleIdx*6, GL_UNSIGNED_SHORT, 0); - glBindVertexArray( 0 ); - CC_INCREMENT_GL_DRAWS(1); CHECK_GL_ERROR_DEBUG(); diff --git a/vendor/Pods/cocos2d/cocos2d/CCProgressTimer.m b/vendor/Pods/cocos2d/cocos2d/CCProgressTimer.m index 084b0c6..3c5c628 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCProgressTimer.m +++ b/vendor/Pods/cocos2d/cocos2d/CCProgressTimer.m @@ -139,7 +139,7 @@ -(void)setType:(CCProgressTimerType)newType } } --(void)setReverseProgress:(BOOL)reverse +-(void)setReverseDirection:(BOOL)reverse { if( reverseDirection_ != reverse ) { reverseDirection_ = reverse; diff --git a/vendor/Pods/cocos2d/cocos2d/CCProtocols.h b/vendor/Pods/cocos2d/cocos2d/CCProtocols.h index e55ec92..0c73c65 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCProtocols.h +++ b/vendor/Pods/cocos2d/cocos2d/CCProtocols.h @@ -25,7 +25,10 @@ #import "ccMacros.h" #import "ccTypes.h" -#import "CCTexture2D.h" + + +@class CCTexture2D; +@class CCDirector; #pragma mark - #pragma mark CCRGBAProtocol @@ -127,6 +130,10 @@ /** Returns a Boolean value indicating whether the CCDirector supports the specified orientation. Default value is YES (supports all possible orientations) */ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation; +/** Called when projection is resized (due to layoutSubviews on the view). This is important to respond to in order to setup your scene with the proper dimensions (which only exist after the first call to layoutSubviews) so that you can set your scene as early as possible to avoid startup flicker + */ +-(void) directorDidReshapeProjection:(CCDirector*)director; + #endif // __CC_PLATFORM_IOS @end diff --git a/vendor/Pods/cocos2d/cocos2d/CCScene.h b/vendor/Pods/cocos2d/cocos2d/CCScene.h index 36b9085..02f504f 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCScene.h +++ b/vendor/Pods/cocos2d/cocos2d/CCScene.h @@ -40,4 +40,8 @@ @interface CCScene : CCNode { } +/** initializes a node. + The node will be created as "autorelease". + */ +-(id) init; @end diff --git a/vendor/Pods/cocos2d/cocos2d/CCScheduler.h b/vendor/Pods/cocos2d/cocos2d/CCScheduler.h index 9ae05db..509d0b9 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCScheduler.h +++ b/vendor/Pods/cocos2d/cocos2d/CCScheduler.h @@ -42,44 +42,62 @@ typedef void (*TICK_IMP)(id, SEL, ccTime); /** Light weight timer */ @interface CCTimer : NSObject { - id target; - TICK_IMP impMethod; - - ccTime elapsed; - BOOL runForever; - BOOL useDelay; - uint nTimesExecuted; - uint repeat; //0 = once, 1 is 2 x executed - ccTime delay; - -@public // optimization - ccTime interval; - SEL selector; + ccTime _interval; + ccTime _elapsed; + BOOL _runForever; + BOOL _useDelay; + uint _nTimesExecuted; + uint _repeat; //0 = once, 1 is 2 x executed + ccTime _delay; } + /** interval in seconds */ @property (nonatomic,readwrite,assign) ccTime interval; -/** Allocates a timer with a target and a selector. -*/ + +/** triggers the timer */ +-(void) update: (ccTime) dt; +@end + +@interface CCTimerTargetSelector : CCTimer +{ + id _target; + SEL _selector; + TICK_IMP _impMethod; +} + +/** selector */ +@property (nonatomic,readonly) SEL selector; + +/** Allocates a timer with a target and a selector. */ +(id) timerWithTarget:(id) t selector:(SEL)s; -/** Allocates a timer with a target, a selector and an interval in seconds. -*/ +/** Allocates a timer with a target, a selector and an interval in seconds. */ +(id) timerWithTarget:(id) t selector:(SEL)s interval:(ccTime)seconds; -/** Initializes a timer with a target and a selector. -*/ - -(id) initWithTarget:(id) t selector:(SEL)s; +/** Initializes a timer with a target and a selector. */ +-(id) initWithTarget:(id) t selector:(SEL)s; -/** Initializes a timer with a target, a selector, an interval in seconds, repeat in number of times to repeat, delay in seconds -*/ +/** Initializes a timer with a target, a selector, an interval in seconds, repeat in number of times to repeat, delay in seconds */ -(id) initWithTarget:(id)t selector:(SEL)s interval:(ccTime) seconds repeat:(uint) r delay:(ccTime) d; +@end -/** triggers the timer */ --(void) update: (ccTime) dt; -@end +@interface CCTimerBlock : CCTimer +{ + void (^_block)(ccTime delta); + NSString *_key; +} + +/** unique identifier of the block */ +@property (nonatomic, readonly) NSString *key; +/** Allocates a timer with a target, a selector and an interval in seconds. */ ++(id) timerWithInterval:(ccTime)seconds key:(NSString*)key block:(void(^)(ccTime delta)) block; + +/** Initializes a timer Interval in seconds, repeat in number of times to repeat, delay in seconds and a block */ +-(id) initWithInterval:(ccTime)seconds repeat:(uint)r delay:(ccTime) d key:(NSString*)key block:(void(^)(ccTime delta)) block; +@end // @@ -114,7 +132,7 @@ struct _hashUpdateEntry; struct _hashUpdateEntry *hashForUpdates; // hash used to fetch quickly the list entries for pause,delete,etc. // Used for "selectors with interval" - struct _hashSelectorEntry *hashForSelectors; + struct _hashSelectorEntry *hashForTimers; struct _hashSelectorEntry *currentTarget; BOOL currentTargetSalvaged; @@ -143,7 +161,7 @@ struct _hashUpdateEntry; If paused is YES, then it won't be called until it is resumed. If 'interval' is 0, it will be called every frame, but if so, it recommened to use 'scheduleUpdateForTarget:' instead. If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again. - repeat let the action be repeated repeat + 1 times, use kCCRepeatForever to let the action run continiously + repeat lets the action be repeated repeat + 1 times, use kCCRepeatForever to let the action run continiously delay is the amount of time the action will wait before it'll start @since v0.99.3, repeat and delay added in v1.1 @@ -160,12 +178,30 @@ struct _hashUpdateEntry; */ -(void) scheduleUpdateForTarget:(id)target priority:(NSInteger)priority paused:(BOOL)paused; +/** The scheduled block will be called every 'interval' seconds. + If paused is YES, then it won't be called until it is resumed. + If 'interval' is 0, it will be called every frame, but if so, it recommened to use 'scheduleUpdateForTarget:' instead. + If the block is already scheduled, then only the interval parameter will be updated without re-scheduling it again. + 'repeat' lets the action be repeated repeat + 1 times, use kCCRepeatForever to let the action run continiously. + 'delay' is the amount of time the action will wait before it'll start. + 'target' is needed for all the method related to "target" like "pause" and "unschedule" + 'key' is a unique identifier of the block. Needed to unschedule the block or update its interval. + @since v2.1 + */ +-(void) scheduleBlockForKey:(NSString*)key target:(id)target interval:(ccTime)interval paused:(BOOL)paused repeat:(uint)repeat delay:(ccTime)delay block:(void(^)(ccTime dt))block; + /** Unshedules a selector for a given target. If you want to unschedule the "update", use unscheudleUpdateForTarget. @since v0.99.3 */ -(void) unscheduleSelector:(SEL)selector forTarget:(id)target; +/** Unshedules a block for a given key / target pair. + If you want to unschedule the "update", use unscheudleUpdateForTarget. + @since v2.1 + */ +-(void) unscheduleBlockForKey:(NSString*)key target:(id)target; + /** Unschedules the update selector for a given target @since v0.99.3 */ diff --git a/vendor/Pods/cocos2d/cocos2d/CCScheduler.m b/vendor/Pods/cocos2d/cocos2d/CCScheduler.m index f99e18a..0ef56cf 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCScheduler.m +++ b/vendor/Pods/cocos2d/cocos2d/CCScheduler.m @@ -67,26 +67,107 @@ BOOL currentTimerSalvaged; BOOL paused; UT_hash_handle hh; -} tHashSelectorEntry; +} tHashTimerEntry; // // CCTimer // -#pragma mark - #pragma mark - CCTimer +@interface CCTimer () +-(void) setupTimerWithInterval:(ccTime)seconds repeat:(uint)r delay:(ccTime)d; +-(void) trigger; +-(void) cancel; +@end + @implementation CCTimer -@synthesize interval; +@synthesize interval=_interval; --(id) init +-(void) setupTimerWithInterval:(ccTime)seconds repeat:(uint)r delay:(ccTime)d { - NSAssert(NO, @"CCTimer: Init not supported."); - [self release]; - return nil; + _elapsed = -1; + _interval = seconds; + _repeat = r; + _delay = d; + _useDelay = (_delay > 0) ? YES : NO; + _repeat = r; + _runForever = (_repeat == kCCRepeatForever) ? YES : NO; +} + +-(void) dealloc +{ + CCLOGINFO(@"cocos2d: deallocing %@", self); + + [super dealloc]; +} + +-(void) trigger +{ + // override me +} + +-(void) cancel +{ + // override me +} + +-(void) update: (ccTime) dt +{ + if( _elapsed == - 1) + { + _elapsed = 0; + _nTimesExecuted = 0; + } + else + { + if (_runForever && !_useDelay) + {//standard timer usage + _elapsed += dt; + if( _elapsed >= _interval ) { + [self trigger]; + _elapsed = 0; + + } + } + else + {//advanced usage + _elapsed += dt; + if (_useDelay) + { + if( _elapsed >= _delay ) + { + [self trigger]; + _elapsed = _elapsed - _delay; + _nTimesExecuted+=1; + _useDelay = NO; + } + } + else + { + if (_elapsed >= _interval) + { + [self trigger]; + _elapsed = 0; + _nTimesExecuted += 1; + + } + } + + if (_nTimesExecuted > _repeat) + { //unschedule timer + [self cancel]; + } + } + } } +@end + +@implementation CCTimerTargetSelector + +@synthesize selector=_selector; +(id) timerWithTarget:(id)t selector:(SEL)s { @@ -112,83 +193,80 @@ -(id) initWithTarget:(id)t selector:(SEL)s interval:(ccTime) seconds repeat:(uin #endif // target is not retained. It is retained in the hash structure - target = t; - selector = s; - impMethod = (TICK_IMP) [t methodForSelector:s]; - elapsed = -1; - interval = seconds; - repeat = r; - delay = d; - useDelay = (delay > 0) ? YES : NO; - repeat = r; - runForever = (repeat == kCCRepeatForever) ? YES : NO; + _target = t; + _selector = s; + _impMethod = (TICK_IMP) [t methodForSelector:s]; + + [self setupTimerWithInterval:seconds repeat:r delay:d]; } return self; } - - (NSString*) description { - return [NSString stringWithFormat:@"<%@ = %p | target:%@ selector:(%@)>", [self class], self, [target class], NSStringFromSelector(selector)]; + return [NSString stringWithFormat:@"<%@ = %p | target:%@ selector:(%@)>", [self class], self, [_target class], NSStringFromSelector(_selector)]; } --(void) dealloc +-(void) trigger { - CCLOGINFO(@"cocos2d: deallocing %@", self); - [super dealloc]; + _impMethod(_target, _selector, _elapsed); } --(void) update: (ccTime) dt +-(void) cancel { - if( elapsed == - 1) - { - elapsed = 0; - nTimesExecuted = 0; - } - else - { - if (runForever && !useDelay) - {//standard timer usage - elapsed += dt; - if( elapsed >= interval ) { - impMethod(target, selector, elapsed); - elapsed = 0; + [[[CCDirector sharedDirector] scheduler] unscheduleSelector:_selector forTarget:_target]; +} - } - } - else - {//advanced usage - elapsed += dt; - if (useDelay) - { - if( elapsed >= delay ) - { - impMethod(target, selector, elapsed); - elapsed = elapsed - delay; - nTimesExecuted+=1; - useDelay = NO; - } - } - else - { - if (elapsed >= interval) - { - impMethod(target, selector, elapsed); - elapsed = 0; - nTimesExecuted += 1; +@end - } - } +@implementation CCTimerBlock - if (nTimesExecuted > repeat) - { //unschedule timer - [[[CCDirector sharedDirector] scheduler] unscheduleSelector:selector forTarget:target]; - } - } +@synthesize key=_key; + ++(id) timerWithInterval:(ccTime)seconds key:(NSString*)key block:(void(^)(ccTime delta)) block +{ + return [[[self alloc] initWithInterval:seconds repeat:kCCRepeatForever delay:0 key:key block:block] autorelease]; +} + +-(id) initWithInterval:(ccTime) seconds repeat:(uint) r delay:(ccTime)d key:(NSString*)key block:(void(^)(ccTime delta))block +{ + if( (self=[super init]) ) { + _block = [block copy]; + _key = [key copy]; + + [self setupTimerWithInterval:seconds repeat:r delay:d]; } + + return self; +} + +- (NSString*) description +{ + return [NSString stringWithFormat:@"<%@ = %p | block>", [self class], self]; } + +- (void)dealloc +{ + [_key release]; + [_block release]; + + [super dealloc]; +} + +-(void) trigger +{ + _block( _elapsed); +} + +-(void) cancel +{ +// [[[CCDirector sharedDirector] scheduler] unscheduleSelector:_selector forTarget:_target]; +} + @end + + // // CCScheduler // @@ -196,7 +274,7 @@ -(void) update: (ccTime) dt #pragma mark - CCScheduler @interface CCScheduler (Private) --(void) removeHashElement:(tHashSelectorEntry*)element; +-(void) removeHashElement:(tHashTimerEntry*)element; @end @implementation CCScheduler @@ -210,7 +288,7 @@ - (id) init // used to trigger CCTimer#update updateSelector = @selector(update:); - impMethod = (TICK_IMP) [CCTimer instanceMethodForSelector:updateSelector]; + impMethod = (TICK_IMP) [CCTimerTargetSelector instanceMethodForSelector:updateSelector]; // updates with priority updates0 = NULL; @@ -221,7 +299,7 @@ - (id) init // selectors with interval currentTarget = nil; currentTargetSalvaged = NO; - hashForSelectors = nil; + hashForTimers = nil; updateHashLocked = NO; } @@ -243,13 +321,13 @@ - (void) dealloc } -#pragma mark CCScheduler - Custom Selectors +#pragma mark CCScheduler - Timers --(void) removeHashElement:(tHashSelectorEntry*)element +-(void) removeHashElement:(tHashTimerEntry*)element { ccArrayFree(element->timers); [element->target release]; - HASH_DEL(hashForSelectors, element); + HASH_DEL(hashForTimers, element); free(element); } @@ -263,13 +341,13 @@ -(void) scheduleSelector:(SEL)selector forTarget:(id)target interval:(ccTime)int NSAssert( selector != nil, @"Argument selector must be non-nil"); NSAssert( target != nil, @"Argument target must be non-nil"); - tHashSelectorEntry *element = NULL; - HASH_FIND_INT(hashForSelectors, &target, element); + tHashTimerEntry *element = NULL; + HASH_FIND_INT(hashForTimers, &target, element); if( ! element ) { element = calloc( sizeof( *element ), 1 ); element->target = [target retain]; - HASH_ADD_INT( hashForSelectors, target, element ); + HASH_ADD_INT( hashForTimers, target, element ); // Is this the 1st element ? Then set the pause level to all the selectors of this target element->paused = paused; @@ -284,16 +362,56 @@ -(void) scheduleSelector:(SEL)selector forTarget:(id)target interval:(ccTime)int { for( unsigned int i=0; i< element->timers->num; i++ ) { CCTimer *timer = element->timers->arr[i]; - if( selector == timer->selector ) { - CCLOG(@"CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f", timer->interval, interval); - timer->interval = interval; + if( [timer isKindOfClass:[CCTimerTargetSelector class]] && selector == [(CCTimerTargetSelector*)timer selector] ) { + CCLOG(@"CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f", [timer interval], interval); + [timer setInterval: interval]; return; } } ccArrayEnsureExtraCapacity(element->timers, 1); } - CCTimer *timer = [[CCTimer alloc] initWithTarget:target selector:selector interval:interval repeat:repeat delay:delay]; + CCTimerTargetSelector *timer = [[CCTimerTargetSelector alloc] initWithTarget:target selector:selector interval:interval repeat:repeat delay:delay]; + ccArrayAppendObject(element->timers, timer); + [timer release]; +} + +-(void) scheduleBlockForKey:(NSString*)key target:(id)owner interval:(ccTime)interval paused:(BOOL)paused repeat:(uint)repeat delay:(ccTime)delay block:(void(^)(ccTime dt))block +{ + NSAssert( block != nil, @"Argument block must be non-nil"); + NSAssert( owner != nil, @"Argument owner must be non-nil"); + + tHashTimerEntry *element = NULL; + HASH_FIND_INT(hashForTimers, &owner, element); + + if( ! element ) { + element = calloc( sizeof( *element ), 1 ); + element->target = [owner retain]; + HASH_ADD_INT( hashForTimers, target, element ); + + // Is this the 1st element ? Then set the pause level to all the selectors of this target + element->paused = paused; + + } else + NSAssert( element->paused == paused, @"CCScheduler. Trying to schedule a block with a pause value different than the target"); + + + if( element->timers == nil ) + element->timers = ccArrayNew(10); + else + { + for( unsigned int i=0; i< element->timers->num; i++ ) { + CCTimer *timer = element->timers->arr[i]; + if( [timer isKindOfClass:[CCTimerBlock class]] && [key isEqualToString:[(CCTimerBlock*)timer key] ] ) { + CCLOG(@"CCScheduler#scheduleBlock. Block already scheduled. Updating interval from: %.4f to %.4f", [timer interval], interval); + [timer setInterval: interval]; + return; + } + } + ccArrayEnsureExtraCapacity(element->timers, 1); + } + + CCTimerBlock *timer = [[CCTimerBlock alloc] initWithInterval:interval repeat:repeat delay:delay key:key block:block]; ccArrayAppendObject(element->timers, timer); [timer release]; } @@ -303,12 +421,59 @@ -(void) unscheduleSelector:(SEL)selector forTarget:(id)target // explicity handle nil arguments when removing an object if( target==nil && selector==NULL) return; - + NSAssert( target != nil, @"Target MUST not be nil"); NSAssert( selector != NULL, @"Selector MUST not be NULL"); + + tHashTimerEntry *element = NULL; + HASH_FIND_INT(hashForTimers, &target, element); + + if( element ) { + + for( unsigned int i=0; i< element->timers->num; i++ ) { + CCTimer *timer = element->timers->arr[i]; + + + if( [timer isKindOfClass:[CCTimerTargetSelector class]] && selector == [(CCTimerTargetSelector*)timer selector] ) { + + if( timer == element->currentTimer && !element->currentTimerSalvaged ) { + [element->currentTimer retain]; + element->currentTimerSalvaged = YES; + } + + ccArrayRemoveObjectAtIndex(element->timers, i ); + + // update timerIndex in case we are in tick:, looping over the actions + if( element->timerIndex >= i ) + element->timerIndex--; + + if( element->timers->num == 0 ) { + if( currentTarget == element ) + currentTargetSalvaged = YES; + else + [self removeHashElement: element]; + } + return; + } + } + } + + // Not Found + // NSLog(@"CCScheduler#unscheduleSelector:forTarget: selector not found: %@", selString); + +} + +-(void) unscheduleBlockForKey:(NSString*)key target:(id)target +{ + // explicity handle nil arguments when removing an object + if( target==nil && key==NULL) + return; - tHashSelectorEntry *element = NULL; - HASH_FIND_INT(hashForSelectors, &target, element); + NSAssert( target != nil, @"Target MUST not be nil"); + NSAssert( key != NULL, @"key MUST not be NULL"); + + tHashTimerEntry *element = NULL; + HASH_FIND_INT(hashForTimers, &target, element); if( element ) { @@ -316,7 +481,7 @@ -(void) unscheduleSelector:(SEL)selector forTarget:(id)target CCTimer *timer = element->timers->arr[i]; - if( selector == timer->selector ) { + if( [timer isKindOfClass:[CCTimerBlock class]] && [key isEqualToString: [(CCTimerBlock*)timer key]] ) { if( timer == element->currentTimer && !element->currentTimerSalvaged ) { [element->currentTimer retain]; @@ -342,7 +507,6 @@ -(void) unscheduleSelector:(SEL)selector forTarget:(id)target // Not Found // NSLog(@"CCScheduler#unscheduleSelector:forTarget: selector not found: %@", selString); - } #pragma mark CCScheduler - Update Specific @@ -498,7 +662,7 @@ -(void) unscheduleAllSelectors -(void) unscheduleAllSelectorsWithMinPriority:(NSInteger)minPriority { // Custom Selectors - for(tHashSelectorEntry *element=hashForSelectors; element != NULL; ) { + for(tHashTimerEntry *element=hashForTimers; element != NULL; ) { id target = element->target; element=element->hh.next; [self unscheduleAllSelectorsForTarget:target]; @@ -533,8 +697,8 @@ -(void) unscheduleAllSelectorsForTarget:(id)target return; // Custom Selectors - tHashSelectorEntry *element = NULL; - HASH_FIND_INT(hashForSelectors, &target, element); + tHashTimerEntry *element = NULL; + HASH_FIND_INT(hashForTimers, &target, element); if( element ) { if( ccArrayContainsObject(element->timers, element->currentTimer) && !element->currentTimerSalvaged ) { @@ -557,8 +721,8 @@ -(void) resumeTarget:(id)target NSAssert( target != nil, @"target must be non nil" ); // Custom Selectors - tHashSelectorEntry *element = NULL; - HASH_FIND_INT(hashForSelectors, &target, element); + tHashTimerEntry *element = NULL; + HASH_FIND_INT(hashForTimers, &target, element); if( element ) element->paused = NO; @@ -576,8 +740,8 @@ -(void) pauseTarget:(id)target NSAssert( target != nil, @"target must be non nil" ); // Custom selectors - tHashSelectorEntry *element = NULL; - HASH_FIND_INT(hashForSelectors, &target, element); + tHashTimerEntry *element = NULL; + HASH_FIND_INT(hashForTimers, &target, element); if( element ) element->paused = YES; @@ -596,8 +760,8 @@ -(BOOL) isTargetPaused:(id)target NSAssert( target != nil, @"target must be non nil" ); // Custom selectors - tHashSelectorEntry *element = NULL; - HASH_FIND_INT(hashForSelectors, &target, element); + tHashTimerEntry *element = NULL; + HASH_FIND_INT(hashForTimers, &target, element); if( element ) { return element->paused; @@ -616,7 +780,7 @@ -(NSSet*) pauseAllTargetsWithMinPriority:(NSInteger)minPriority NSMutableSet* idsWithSelectors = [NSMutableSet setWithCapacity:50]; // Custom Selectors - for(tHashSelectorEntry *element=hashForSelectors; element != NULL; element=element->hh.next) { + for(tHashTimerEntry *element=hashForTimers; element != NULL; element=element->hh.next) { element->paused = YES; [idsWithSelectors addObject:element->target]; } @@ -686,8 +850,8 @@ -(void) update: (ccTime) dt entry->impMethod( entry->target, updateSelector, dt ); } - // Iterate all over the custome selectors - for(tHashSelectorEntry *elt=hashForSelectors; elt != NULL; ) { + // Iterate all over the custom selectors (CCTimers) + for(tHashTimerEntry *elt=hashForTimers; elt != NULL; ) { currentTarget = elt; currentTargetSalvaged = NO; diff --git a/vendor/Pods/cocos2d/cocos2d/CCShaderCache.m b/vendor/Pods/cocos2d/cocos2d/CCShaderCache.m index db701cf..133fdf0 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCShaderCache.m +++ b/vendor/Pods/cocos2d/cocos2d/CCShaderCache.m @@ -199,6 +199,23 @@ -(void) loadDefaultShaders [p release]; CHECK_GL_ERROR_DEBUG(); + + // + // Position, Legth(TexCoords, Color (used by Draw Node basically ) + // + p = [[CCGLProgram alloc] initWithVertexShaderByteArray:ccPositionColorLengthTexture_vert + fragmentShaderByteArray:ccPositionColorLengthTexture_frag]; + + [p addAttribute:kCCAttributeNamePosition index:kCCVertexAttrib_Position]; + [p addAttribute:kCCAttributeNameTexCoord index:kCCVertexAttrib_TexCoords]; + [p addAttribute:kCCAttributeNameColor index:kCCVertexAttrib_Color]; + + [p link]; + [p updateUniforms]; + + [programs_ setObject:p forKey:kCCShader_PositionLengthTexureColor]; + [p release]; + CHECK_GL_ERROR_DEBUG(); } -(CCGLProgram *) programForKey:(NSString*)key diff --git a/vendor/Pods/cocos2d/cocos2d/CCSprite.m b/vendor/Pods/cocos2d/cocos2d/CCSprite.m index 67478d8..8b04604 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCSprite.m +++ b/vendor/Pods/cocos2d/cocos2d/CCSprite.m @@ -51,7 +51,7 @@ #if CC_SPRITEBATCHNODE_RENDER_SUBPIXEL #define RENDER_IN_SUBPIXEL #else -#define RENDER_IN_SUBPIXEL(__A__) ( (int)(__A__)) +#define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__)) #endif @@ -704,6 +704,18 @@ -(void)setRotation:(float)rot SET_DIRTY_RECURSIVELY(); } +-(void)setRotationX:(float)rot +{ + [super setRotationX:rot]; + SET_DIRTY_RECURSIVELY(); +} + +-(void)setRotationY:(float)rot +{ + [super setRotationY:rot]; + SET_DIRTY_RECURSIVELY(); +} + -(void)setSkewX:(float)sx { [super setSkewX:sx]; diff --git a/vendor/Pods/cocos2d/cocos2d/CCSpriteFrame.h b/vendor/Pods/cocos2d/cocos2d/CCSpriteFrame.h index fcc8084..88e54ee 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCSpriteFrame.h +++ b/vendor/Pods/cocos2d/cocos2d/CCSpriteFrame.h @@ -53,7 +53,7 @@ /** rect of the frame in points. If it is updated, then rectInPixels will be updated too. */ @property (nonatomic,readwrite) CGRect rect; -/** rect of the frame in pixels. If it is updated, then rect (points) will be udpated too. */ +/** rect of the frame in pixels. If it is updated, then rect (points) will be updated too. */ @property (nonatomic,readwrite) CGRect rectInPixels; /** whether or not the rect of the frame is rotated ( x = x+width, y = y+height, width = height, height = width ) */ diff --git a/vendor/Pods/cocos2d/cocos2d/CCTexture2D.h b/vendor/Pods/cocos2d/cocos2d/CCTexture2D.h index 415a3b8..e816714 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCTexture2D.h +++ b/vendor/Pods/cocos2d/cocos2d/CCTexture2D.h @@ -121,9 +121,7 @@ typedef enum { BOOL hasPremultipliedAlpha_; BOOL hasMipmaps_; -#ifdef __CC_PLATFORM_IOS ccResolutionType resolutionType_; -#endif // needed for drawAtRect, drawInPoint CCGLProgram *shaderProgram_; @@ -159,17 +157,15 @@ typedef enum { /** shader program used by drawAtPoint and drawInRect */ @property(nonatomic,readwrite,retain) CCGLProgram *shaderProgram; -#ifdef __CC_PLATFORM_IOS /** Returns the resolution type of the texture. - Is it a RetinaDisplay texture, an iPad texture or an standard texture ? - Only valid on iOS. Not valid on OS X. + Is it a RetinaDisplay texture, an iPad texture, a Mac, a Mac RetinaDisplay or an standard texture ? Should be a readonly property. It is readwrite as a hack. @since v1.1 */ @property (nonatomic, readwrite) ccResolutionType resolutionType; -#endif + /** returns the content size of the texture in points */ -(CGSize) contentSize; @@ -194,11 +190,7 @@ Note that RGBA type textures will have their alpha premultiplied - use the blend */ @interface CCTexture2D (Image) /** Initializes a texture from a CGImage object */ -#ifdef __CC_PLATFORM_IOS - (id) initWithCGImage:(CGImageRef)cgImage resolutionType:(ccResolutionType)resolution; -#elif defined(__CC_PLATFORM_MAC) -- (id) initWithCGImage:(CGImageRef)cgImage; -#endif @end /** @@ -212,9 +204,9 @@ Note that the generated textures are of type A8 - use the blending mode (GL_SRC_ - Mac: Only NSLineBreakByWordWrapping is supported. @since v1.0 */ -- (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment) vertAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size; +- (id) initWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment) vertAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode ; /** Initializes a texture from a string with dimensions, alignment, font name and font size */ -- (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment) vertAlignment fontName:(NSString*)name fontSize:(CGFloat)size; +- (id) initWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment) vertAlignment; /** Initializes a texture from a string with font name and font size */ - (id) initWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size; @end diff --git a/vendor/Pods/cocos2d/cocos2d/CCTexture2D.m b/vendor/Pods/cocos2d/cocos2d/CCTexture2D.m index ad9c4fd..34bdd85 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCTexture2D.m +++ b/vendor/Pods/cocos2d/cocos2d/CCTexture2D.m @@ -110,10 +110,7 @@ @implementation CCTexture2D @synthesize contentSizeInPixels = size_, pixelFormat = format_, pixelsWide = width_, pixelsHigh = height_, name = name_, maxS = maxS_, maxT = maxT_; @synthesize hasPremultipliedAlpha = hasPremultipliedAlpha_; @synthesize shaderProgram = shaderProgram_; - -#ifdef __CC_PLATFORM_IOS @synthesize resolutionType = resolutionType_; -#endif - (id) initWithData:(const void*)data pixelFormat:(CCTexture2DPixelFormat)pixelFormat pixelsWide:(NSUInteger)width pixelsHigh:(NSUInteger)height contentSize:(CGSize)size @@ -176,9 +173,7 @@ - (id) initWithData:(const void*)data pixelFormat:(CCTexture2DPixelFormat)pixelF hasMipmaps_ = NO; -#ifdef __CC_PLATFORM_IOS resolutionType_ = kCCResolutionUnknown; -#endif self.shaderProgram = [[CCShaderCache sharedShaderCache] programForKey:kCCShader_PositionTexture]; } return self; @@ -229,11 +224,7 @@ -(CGSize) contentSize @implementation CCTexture2D (Image) -#ifdef __CC_PLATFORM_IOS - (id) initWithCGImage:(CGImageRef)cgImage resolutionType:(ccResolutionType)resolution -#elif defined(__CC_PLATFORM_MAC) -- (id) initWithCGImage:(CGImageRef)cgImage -#endif { NSUInteger textureWidth, textureHeight; CGContextRef context = nil; @@ -454,9 +445,7 @@ We need to check new alpha value first (it may be 1 or 0) and depending on it wh CGContextRelease(context); [self releaseData:data]; -#ifdef __CC_PLATFORM_IOS resolutionType_ = resolution; -#endif return self; } @@ -663,12 +652,12 @@ - (id) initWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFlo } -- (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment)vAlignment fontName:(NSString*)name fontSize:(CGFloat)size +- (id) initWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment)vAlignment { - return [self initWithString:string dimensions:dimensions hAlignment:alignment vAlignment:vAlignment lineBreakMode:kCCLineBreakModeWordWrap fontName:name fontSize:size]; + return [self initWithString:string fontName:name fontSize:size dimensions:dimensions hAlignment:alignment vAlignment:vAlignment lineBreakMode:kCCLineBreakModeWordWrap]; } -- (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)hAlignment vAlignment:(CCVerticalTextAlignment)vAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size +- (id) initWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)hAlignment vAlignment:(CCVerticalTextAlignment)vAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode { #ifdef __CC_PLATFORM_IOS UIFont *uifont = [UIFont fontWithName:name size:size]; @@ -722,14 +711,9 @@ @implementation CCTexture2D (PVRSupport) -(id) initWithPVRFile: (NSString*) relPath { -#ifdef __CC_PLATFORM_IOS ccResolutionType resolution; NSString *fullpath = [[CCFileUtils sharedFileUtils] fullPathFromRelativePath:relPath resolutionType:&resolution]; -#elif defined(__CC_PLATFORM_MAC) - NSString *fullpath = [[CCFileUtils sharedFileUtils] fullPathFromRelativePath:relPath]; -#endif - if( (self = [super init]) ) { CCTexturePVR *pvr = [[CCTexturePVR alloc] initWithContentsOfFile:fullpath]; if( pvr ) { @@ -753,9 +737,7 @@ -(id) initWithPVRFile: (NSString*) relPath [self release]; return nil; } -#ifdef __CC_PLATFORM_IOS resolutionType_ = resolution; -#endif } return self; } @@ -787,7 +769,7 @@ - (void) drawAtPoint:(CGPoint)point ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_TexCoords ); [shaderProgram_ use]; - [shaderProgram_ setUniformForModelViewProjectionMatrix]; + [shaderProgram_ setUniformsForBuiltins]; ccGLBindTexture2D( name_ ); @@ -815,7 +797,7 @@ - (void) drawInRect:(CGRect)rect [shaderProgram_ use]; - [shaderProgram_ setUniformForModelViewProjectionMatrix]; + [shaderProgram_ setUniformsForBuiltins]; ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_TexCoords ); diff --git a/vendor/Pods/cocos2d/cocos2d/CCTextureAtlas.h b/vendor/Pods/cocos2d/cocos2d/CCTextureAtlas.h index 4a61485..ff7d117 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCTextureAtlas.h +++ b/vendor/Pods/cocos2d/cocos2d/CCTextureAtlas.h @@ -31,7 +31,7 @@ /** A class that implements a Texture Atlas. Supported features: * The atlas file can be a PVRTC, PNG or any other fomrat supported by Texture2D - * Quads can be udpated in runtime + * Quads can be updated in runtime * Quads can be added in runtime * Quads can be removed in runtime * Quads can be re-ordered in runtime diff --git a/vendor/Pods/cocos2d/cocos2d/CCTextureAtlas.m b/vendor/Pods/cocos2d/cocos2d/CCTextureAtlas.m index 5e703bf..d323478 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCTextureAtlas.m +++ b/vendor/Pods/cocos2d/cocos2d/CCTextureAtlas.m @@ -181,7 +181,7 @@ -(void) setupVBOandVAO void (^createVAO)(void) = ^{ glGenVertexArrays(1, &VAOname_); - glBindVertexArray(VAOname_); + ccGLBindVAO(VAOname_); #define kQuadSize sizeof(quads_[0].bl) @@ -205,7 +205,8 @@ -(void) setupVBOandVAO glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffersVBO_[1]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices_[0]) * capacity_ * 6, indices_, GL_STATIC_DRAW); - glBindVertexArray(0); + // Must unbind the VAO before changing the element buffer. + ccGLBindVAO(0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -230,6 +231,9 @@ -(void) setupVBO -(void) mapBuffers { + // Avoid changing the element buffer for whatever VAO might be bound. + ccGLBindVAO(0); + glBindBuffer(GL_ARRAY_BUFFER, buffersVBO_[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * capacity_, quads_, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -500,7 +504,7 @@ -(void) drawNumberOfQuads: (NSUInteger) n fromIndex: (NSUInteger) start dirty_ = NO; } - glBindVertexArray( VAOname_ ); + ccGLBindVAO( VAOname_ ); #if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP glDrawElements(GL_TRIANGLE_STRIP, (GLsizei) n*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(indices_[0])) ); @@ -508,7 +512,7 @@ -(void) drawNumberOfQuads: (NSUInteger) n fromIndex: (NSUInteger) start glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(indices_[0])) ); #endif // CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP - glBindVertexArray(0); +// glBindVertexArray(0); #else // ! CC_TEXTURE_ATLAS_USE_VAO @@ -523,6 +527,9 @@ -(void) drawNumberOfQuads: (NSUInteger) n fromIndex: (NSUInteger) start // XXX: update is done in draw... perhaps it should be done in a timer if (dirty_) { glBufferSubData(GL_ARRAY_BUFFER, sizeof(quads_[0])*start, sizeof(quads_[0]) * n , &quads_[start] ); + + // Apparently this is faster... need to do performance tests +// glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * n, quads_, GL_DYNAMIC_DRAW); dirty_ = NO; } diff --git a/vendor/Pods/cocos2d/cocos2d/CCTextureCache.m b/vendor/Pods/cocos2d/cocos2d/CCTextureCache.m index e151e39..29c1dc8 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCTextureCache.m +++ b/vendor/Pods/cocos2d/cocos2d/CCTextureCache.m @@ -288,13 +288,13 @@ -(CCTexture2D*) addImage: (NSString*) path // all images are handled by UIKit/AppKit except PVR extension that is handled by cocos2d's handler + if ( [lowerCase hasSuffix:@".pvr"] || [lowerCase hasSuffix:@".pvr.gz"] || [lowerCase hasSuffix:@".pvr.ccz"] ) tex = [self addPVRImage:path]; #ifdef __CC_PLATFORM_IOS else { - ccResolutionType resolution; NSString *fullpath = [[CCFileUtils sharedFileUtils] fullPathFromRelativePath:path resolutionType:&resolution]; @@ -317,11 +317,12 @@ -(CCTexture2D*) addImage: (NSString*) path #elif defined(__CC_PLATFORM_MAC) else { - NSString *fullpath = [[CCFileUtils sharedFileUtils] fullPathFromRelativePath: path ]; + ccResolutionType resolution; + NSString *fullpath = [[CCFileUtils sharedFileUtils] fullPathFromRelativePath:path resolutionType:&resolution]; NSData *data = [[NSData alloc] initWithContentsOfFile:fullpath]; NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithData:data]; - tex = [ [CCTexture2D alloc] initWithCGImage:[image CGImage]]; + tex = [ [CCTexture2D alloc] initWithCGImage:[image CGImage] resolutionType:resolution]; [data release]; [image release]; @@ -360,11 +361,7 @@ -(CCTexture2D*) addCGImage: (CGImageRef) imageref forKey: (NSString *)key return tex; } -#ifdef __CC_PLATFORM_IOS tex = [[CCTexture2D alloc] initWithCGImage:imageref resolutionType:kCCResolutionUnknown]; -#elif __CC_PLATFORM_MAC - tex = [[CCTexture2D alloc] initWithCGImage:imageref]; -#endif if(tex && key){ dispatch_sync(_dictQueue, ^{ diff --git a/vendor/Pods/cocos2d/cocos2d/CCTexturePVR.h b/vendor/Pods/cocos2d/cocos2d/CCTexturePVR.h index f490818..2352db3 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCTexturePVR.h +++ b/vendor/Pods/cocos2d/cocos2d/CCTexturePVR.h @@ -59,6 +59,16 @@ struct CCPVRMipmap { unsigned int len; }; +typedef struct _ccPVRTexturePixelFormatInfo { + GLenum internalFormat; + GLenum format; + GLenum type; + uint32_t bpp; + BOOL compressed; + BOOL alpha; + CCTexture2DPixelFormat ccPixelFormat; +} ccPVRTexturePixelFormatInfo; + enum { CC_PVRMIPMAP_MAX = 16, }; @@ -90,7 +100,6 @@ enum { struct CCPVRMipmap mipmaps_[CC_PVRMIPMAP_MAX]; // pointer to mipmap images NSUInteger numberOfMipmaps_; // number of mipmap used - unsigned int tableFormatIndex_; uint32_t width_, height_; GLuint name_; BOOL hasAlpha_; @@ -98,6 +107,8 @@ enum { // cocos2d integration BOOL retainName_; CCTexture2DPixelFormat format_; + + const ccPVRTexturePixelFormatInfo *_pixelFormatInfo; } /** initializes a CCTexturePVR with a path */ diff --git a/vendor/Pods/cocos2d/cocos2d/CCTexturePVR.m b/vendor/Pods/cocos2d/cocos2d/CCTexturePVR.m index 39d2829..40d74e9 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCTexturePVR.m +++ b/vendor/Pods/cocos2d/cocos2d/CCTexturePVR.m @@ -56,6 +56,8 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * - A8 * - I8 * - AI88 + * + * Added support for PVR v3 file format */ #import @@ -74,6 +76,52 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #define PVR_TEXTURE_FLAG_TYPE_MASK 0xff +#pragma mark PVR File format - common + +// +// XXX DO NO ALTER THE ORDER IN THIS LIST XXX +// +static const ccPVRTexturePixelFormatInfo PVRTableFormats[] = { + + // 0: BGRA_8888 + {GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, NO, YES, kCCTexture2DPixelFormat_RGBA8888}, + // 1: RGBA_8888 + {GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, NO, YES, kCCTexture2DPixelFormat_RGBA8888}, + // 2: RGBA_4444 + {GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, NO, YES, kCCTexture2DPixelFormat_RGBA4444}, + // 3: RGBA_5551 + {GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, NO, YES, kCCTexture2DPixelFormat_RGB5A1}, + // 4: RGB_565 + {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, NO, NO, kCCTexture2DPixelFormat_RGB565}, + // 5: RGB_888 + {GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, 24, NO, NO, kCCTexture2DPixelFormat_RGB888}, + // 6: A_8 + {GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, 8, NO, NO, kCCTexture2DPixelFormat_A8}, + // 7: L_8 + {GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, NO, NO, kCCTexture2DPixelFormat_I8}, + // 8: LA_88 + {GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 16, NO, YES, kCCTexture2DPixelFormat_AI88}, + +#ifdef __CC_PLATFORM_IOS + // 9: PVRTC 2BPP RGB + {GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, -1, -1, 2, YES, NO, kCCTexture2DPixelFormat_PVRTC2}, + // 10: PVRTC 2BPP RGBA + {GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1, 2, YES, YES, kCCTexture2DPixelFormat_PVRTC2}, + // 11: PVRTC 4BPP RGB + {GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, -1, -1, 4, YES, NO, kCCTexture2DPixelFormat_PVRTC4}, + // 12: PVRTC 4BPP RGBA + {GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1, 4, YES, YES, kCCTexture2DPixelFormat_PVRTC4}, +#endif // #__CC_PLATFORM_IOS +}; + +struct _pixelformat_hash { + uint64_t pixelFormat; + const ccPVRTexturePixelFormatInfo * pixelFormatInfo; +}; + + +#pragma mark PVR File formats for v2 and v3 + // Values taken from PVRTexture.h from http://www.imgtec.com enum { kPVRTextureFlagMipmap = (1<<8), // has mip map levels @@ -90,57 +138,87 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE static char gPVRTexIdentifier[4] = "PVR!"; -enum +// v2 +typedef enum { - kPVRTexturePixelTypeRGBA_4444= 0x10, - kPVRTexturePixelTypeRGBA_5551, - kPVRTexturePixelTypeRGBA_8888, - kPVRTexturePixelTypeRGB_565, - kPVRTexturePixelTypeRGB_555, // unsupported - kPVRTexturePixelTypeRGB_888, - kPVRTexturePixelTypeI_8, - kPVRTexturePixelTypeAI_88, - kPVRTexturePixelTypePVRTC_2, - kPVRTexturePixelTypePVRTC_4, - kPVRTexturePixelTypeBGRA_8888, - kPVRTexturePixelTypeA_8, -}; + kPVR2TexturePixelFormat_RGBA_4444= 0x10, + kPVR2TexturePixelFormat_RGBA_5551, + kPVR2TexturePixelFormat_RGBA_8888, + kPVR2TexturePixelFormat_RGB_565, + kPVR2TexturePixelFormat_RGB_555, // unsupported + kPVR2TexturePixelFormat_RGB_888, + kPVR2TexturePixelFormat_I_8, + kPVR2TexturePixelFormat_AI_88, + kPVR2TexturePixelFormat_PVRTC_2BPP_RGBA, + kPVR2TexturePixelFormat_PVRTC_4BPP_RGBA, + kPVR2TexturePixelFormat_BGRA_8888, + kPVR2TexturePixelFormat_A_8, +} ccPVR2TexturePixelFormat; + +// v3 +typedef enum { + /* supported predefined formats */ + kPVR3TexturePixelFormat_PVRTC_2BPP_RGB = 0, + kPVR3TexturePixelFormat_PVRTC_2BPP_RGBA = 1, + kPVR3TexturePixelFormat_PVRTC_4BPP_RGB = 2, + kPVR3TexturePixelFormat_PVRTC_4BPP_RGBA = 3, + + /* supported channel type formats */ + kPVR3TexturePixelFormat_BGRA_8888 = 0x0808080861726762, + kPVR3TexturePixelFormat_RGBA_8888 = 0x0808080861626772, + kPVR3TexturePixelFormat_RGBA_4444 = 0x0404040461626772, + kPVR3TexturePixelFormat_RGBA_5551 = 0x0105050561626772, + kPVR3TexturePixelFormat_RGB_565 = 0x0005060500626772, + kPVR3TexturePixelFormat_RGB_888 = 0x0008080800626772, + kPVR3TexturePixelFormat_A_8 = 0x0000000800000061, + kPVR3TexturePixelFormat_L_8 = 0x000000080000006c, + kPVR3TexturePixelFormat_LA_88 = 0x000008080000616c, +} ccPVR3TexturePixelFormat; + +// v2 +static struct _pixelformat_hash v2_pixelformat_hash[] = { + + { kPVR2TexturePixelFormat_BGRA_8888, &PVRTableFormats[0] }, + { kPVR2TexturePixelFormat_RGBA_8888, &PVRTableFormats[1] }, + { kPVR2TexturePixelFormat_RGBA_4444, &PVRTableFormats[2] }, + { kPVR2TexturePixelFormat_RGBA_5551, &PVRTableFormats[3] }, + { kPVR2TexturePixelFormat_RGB_565, &PVRTableFormats[4] }, + { kPVR2TexturePixelFormat_RGB_888, &PVRTableFormats[5] }, + { kPVR2TexturePixelFormat_A_8, &PVRTableFormats[6] }, + { kPVR2TexturePixelFormat_I_8, &PVRTableFormats[7] }, + { kPVR2TexturePixelFormat_AI_88, &PVRTableFormats[8] }, -static const uint32_t tableFormats[][7] = { - - // - PVR texture format - // - OpenGL internal format - // - OpenGL format - // - OpenGL type - // - bpp - // - compressed - // - Cocos2d texture format constant - { kPVRTexturePixelTypeRGBA_4444, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, NO, kCCTexture2DPixelFormat_RGBA4444 }, - { kPVRTexturePixelTypeRGBA_5551, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, NO, kCCTexture2DPixelFormat_RGB5A1 }, - { kPVRTexturePixelTypeRGBA_8888, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, NO, kCCTexture2DPixelFormat_RGBA8888 }, - { kPVRTexturePixelTypeRGB_565, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, NO, kCCTexture2DPixelFormat_RGB565 }, - { kPVRTexturePixelTypeRGB_888, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, 24, NO, kCCTexture2DPixelFormat_RGB888 }, - { kPVRTexturePixelTypeA_8, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, 8, NO, kCCTexture2DPixelFormat_A8 }, - { kPVRTexturePixelTypeI_8, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, NO, kCCTexture2DPixelFormat_I8 }, - { kPVRTexturePixelTypeAI_88, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 16, NO, kCCTexture2DPixelFormat_AI88 }, #ifdef __CC_PLATFORM_IOS - { kPVRTexturePixelTypePVRTC_2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1, 2, YES, kCCTexture2DPixelFormat_PVRTC2 }, - { kPVRTexturePixelTypePVRTC_4, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1, 4, YES, kCCTexture2DPixelFormat_PVRTC4 }, + { kPVR2TexturePixelFormat_PVRTC_2BPP_RGBA, &PVRTableFormats[10] }, + { kPVR2TexturePixelFormat_PVRTC_4BPP_RGBA, &PVRTableFormats[12] }, #endif // iphone only - { kPVRTexturePixelTypeBGRA_8888, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, NO, kCCTexture2DPixelFormat_RGBA8888 }, }; -#define MAX_TABLE_ELEMENTS (sizeof(tableFormats) / sizeof(tableFormats[0])) -enum { - kCCInternalPVRTextureFormat, - kCCInternalOpenGLInternalFormat, - kCCInternalOpenGLFormat, - kCCInternalOpenGLType, - kCCInternalBPP, - kCCInternalCompressedImage, - kCCInternalCCTexture2DPixelFormat, +#define PVR2_MAX_TABLE_ELEMENTS (sizeof(v2_pixelformat_hash) / sizeof(v2_pixelformat_hash[0])) + +// v3 +struct _pixelformat_hash v3_pixelformat_hash[] = { + + {kPVR3TexturePixelFormat_BGRA_8888, &PVRTableFormats[0] }, + {kPVR3TexturePixelFormat_RGBA_8888, &PVRTableFormats[1] }, + {kPVR3TexturePixelFormat_RGBA_4444, &PVRTableFormats[2] }, + {kPVR3TexturePixelFormat_RGBA_5551, &PVRTableFormats[3] }, + {kPVR3TexturePixelFormat_RGB_565, &PVRTableFormats[4] }, + {kPVR3TexturePixelFormat_RGB_888, &PVRTableFormats[5] }, + {kPVR3TexturePixelFormat_A_8, &PVRTableFormats[6] }, + {kPVR3TexturePixelFormat_L_8, &PVRTableFormats[7] }, + {kPVR3TexturePixelFormat_LA_88, &PVRTableFormats[8] }, + +#ifdef __CC_PLATFORM_IOS + {kPVR3TexturePixelFormat_PVRTC_2BPP_RGB, &PVRTableFormats[9] }, + {kPVR3TexturePixelFormat_PVRTC_2BPP_RGBA, &PVRTableFormats[10] }, + {kPVR3TexturePixelFormat_PVRTC_4BPP_RGB, &PVRTableFormats[11] }, + {kPVR3TexturePixelFormat_PVRTC_4BPP_RGBA, &PVRTableFormats[12] }, +#endif // #__CC_PLATFORM_IOS }; +#define PVR3_MAX_TABLE_ELEMENTS (sizeof(v3_pixelformat_hash) / sizeof(v3_pixelformat_hash[0])) + typedef struct _PVRTexHeader { uint32_t headerLength; @@ -156,11 +234,24 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE uint32_t bitmaskAlpha; uint32_t pvrTag; uint32_t numSurfs; -} PVRTexHeader; +} ccPVRv2TexHeader; +typedef struct { + uint32_t version; + uint32_t flags; + uint64_t pixelFormat; + uint32_t colorSpace; + uint32_t channelType; + uint32_t height; + uint32_t width; + uint32_t depth; + uint32_t numberOfSurfaces; + uint32_t numberOfFaces; + uint32_t numberOfMipmaps; + uint32_t metadataLength; +} __attribute__((packed)) ccPVRv3TexHeader ; @implementation CCTexturePVR - @synthesize name = name_; @synthesize width = width_; @synthesize height = height_; @@ -172,10 +263,10 @@ @implementation CCTexturePVR @synthesize format = format_; -- (BOOL)unpackPVRData:(unsigned char*)data PVRLen:(NSUInteger)len +- (BOOL)unpackPVRv2Data:(unsigned char*)data PVRLen:(NSUInteger)len { BOOL success = FALSE; - PVRTexHeader *header = NULL; + ccPVRv2TexHeader *header = NULL; uint32_t flags, pvrTag; uint32_t dataLength = 0, dataOffset = 0, dataSize = 0; uint32_t blockSize = 0, widthBlocks = 0, heightBlocks = 0; @@ -183,7 +274,7 @@ - (BOOL)unpackPVRData:(unsigned char*)data PVRLen:(NSUInteger)len uint8_t *bytes = NULL; uint32_t formatFlags; - header = (PVRTexHeader *)data; + header = (ccPVRv2TexHeader *)data; pvrTag = CFSwapInt32LittleToHost(header->pvrTag); @@ -192,7 +283,6 @@ - (BOOL)unpackPVRData:(unsigned char*)data PVRLen:(NSUInteger)len (uint32_t)gPVRTexIdentifier[2] != ((pvrTag >> 16) & 0xff) || (uint32_t)gPVRTexIdentifier[3] != ((pvrTag >> 24) & 0xff)) { - CCLOG(@"Unsupported PVR format. Use the Legacy format until the new format is supported"); return FALSE; } @@ -210,9 +300,10 @@ - (BOOL)unpackPVRData:(unsigned char*)data PVRLen:(NSUInteger)len return FALSE; } - for( tableFormatIndex_=0; tableFormatIndex_ < (unsigned int)MAX_TABLE_ELEMENTS ; tableFormatIndex_++) { - if( tableFormats[tableFormatIndex_][kCCInternalPVRTextureFormat] == formatFlags ) { + for( NSUInteger i=0; i < (unsigned int)PVR2_MAX_TABLE_ELEMENTS ; i++) { + if( v2_pixelformat_hash[i].pixelFormat == formatFlags ) { + _pixelFormatInfo = v2_pixelformat_hash[i].pixelFormatInfo; numberOfMipmaps_ = 0; width_ = width = CFSwapInt32LittleToHost(header->width); @@ -224,25 +315,25 @@ - (BOOL)unpackPVRData:(unsigned char*)data PVRLen:(NSUInteger)len hasAlpha_ = FALSE; dataLength = CFSwapInt32LittleToHost(header->dataLength); - bytes = ((uint8_t *)data) + sizeof(PVRTexHeader); - format_ = tableFormats[tableFormatIndex_][kCCInternalCCTexture2DPixelFormat]; - bpp = tableFormats[tableFormatIndex_][kCCInternalBPP]; + bytes = ((uint8_t *)data) + sizeof(ccPVRv2TexHeader); + format_ = _pixelFormatInfo->ccPixelFormat; + bpp = _pixelFormatInfo->bpp; // Calculate the data size for each texture level and respect the minimum number of blocks while (dataOffset < dataLength) { switch (formatFlags) { - case kPVRTexturePixelTypePVRTC_2: + case kPVR2TexturePixelFormat_PVRTC_2BPP_RGBA: blockSize = 8 * 4; // Pixel by pixel block size for 2bpp widthBlocks = width / 8; heightBlocks = height / 4; break; - case kPVRTexturePixelTypePVRTC_4: + case kPVR2TexturePixelFormat_PVRTC_4BPP_RGBA: blockSize = 4 * 4; // Pixel by pixel block size for 4bpp widthBlocks = width / 4; heightBlocks = height / 4; break; - case kPVRTexturePixelTypeBGRA_8888: + case kPVR2TexturePixelFormat_BGRA_8888: if( ! [[CCConfiguration sharedConfiguration] supportsBGRA8888] ) { CCLOG(@"cocos2d: TexturePVR. BGRA8888 not supported on this device"); return FALSE; @@ -287,6 +378,107 @@ - (BOOL)unpackPVRData:(unsigned char*)data PVRLen:(NSUInteger)len return success; } +- (BOOL)unpackPVRv3Data:(unsigned char*)dataPointer PVRLen:(NSUInteger)dataLength +{ + if(dataLength < sizeof(ccPVRv3TexHeader)) { + return FALSE; + } + + ccPVRv3TexHeader *header = (ccPVRv3TexHeader *)dataPointer; + + // validate version + if(CFSwapInt32BigToHost(header->version) != 0x50565203) { + CCLOG(@"cocos2d: WARNING: pvr file version mismatch"); + return FALSE; + } + + // parse pixel format + uint64_t pixelFormat = header->pixelFormat; + + + BOOL infoValid = NO; + + for(int i = 0; i < PVR3_MAX_TABLE_ELEMENTS; i++) { + if( v3_pixelformat_hash[i].pixelFormat == pixelFormat ) { + _pixelFormatInfo = v3_pixelformat_hash[i].pixelFormatInfo; + hasAlpha_ = _pixelFormatInfo->alpha; + infoValid = YES; + break; + } + } + + // unsupported / bad pixel format + if(!infoValid) { + CCLOG(@"cocos2d: WARNING: unsupported pvr pixelformat: %llx", pixelFormat ); + return FALSE; + } + + // sizing + uint32_t width = CFSwapInt32LittleToHost(header->width); + uint32_t height = CFSwapInt32LittleToHost(header->height); + width_ = width; + height_ = height; + uint32_t dataOffset = 0, dataSize = 0; + uint32_t blockSize = 0, widthBlocks = 0, heightBlocks = 0; + uint8_t *bytes = NULL; + + dataOffset = (sizeof(ccPVRv3TexHeader) + header->metadataLength); + bytes = dataPointer; + + numberOfMipmaps_ = header->numberOfMipmaps; + NSAssert( numberOfMipmaps_ < CC_PVRMIPMAP_MAX, @"TexturePVR: Maximum number of mimpaps reached. Increate the CC_PVRMIPMAP_MAX value"); + + for(int i = 0; i < numberOfMipmaps_; i++) { + + switch(pixelFormat) { + case kPVR3TexturePixelFormat_PVRTC_2BPP_RGB : + case kPVR3TexturePixelFormat_PVRTC_2BPP_RGBA : + blockSize = 8 * 4; // Pixel by pixel block size for 2bpp + widthBlocks = width / 8; + heightBlocks = height / 4; + break; + case kPVR3TexturePixelFormat_PVRTC_4BPP_RGB : + case kPVR3TexturePixelFormat_PVRTC_4BPP_RGBA : + blockSize = 4 * 4; // Pixel by pixel block size for 4bpp + widthBlocks = width / 4; + heightBlocks = height / 4; + break; + case kPVR3TexturePixelFormat_BGRA_8888: + if( ! [[CCConfiguration sharedConfiguration] supportsBGRA8888] ) { + CCLOG(@"cocos2d: TexturePVR. BGRA8888 not supported on this device"); + return FALSE; + } + default: + blockSize = 1; + widthBlocks = width; + heightBlocks = height; + break; + } + + // Clamp to minimum number of blocks + if (widthBlocks < 2) + widthBlocks = 2; + if (heightBlocks < 2) + heightBlocks = 2; + + dataSize = widthBlocks * heightBlocks * ((blockSize * _pixelFormatInfo->bpp) / 8); + unsigned int packetLength = ((unsigned int)dataLength-dataOffset); + packetLength = packetLength > dataSize ? dataSize : packetLength; + + mipmaps_[i].address = bytes+dataOffset; + mipmaps_[i].len = packetLength; + + dataOffset += packetLength; + NSAssert( dataOffset <= dataLength, @"CCTexurePVR: Invalid lenght"); + + + width = MAX(width >> 1, 1); + height = MAX(height >> 1, 1); + } + + return TRUE; +} + - (BOOL)createGLTexture { @@ -318,10 +510,10 @@ - (BOOL)createGLTexture CHECK_GL_ERROR(); // clean possible GL error - GLenum internalFormat = tableFormats[tableFormatIndex_][kCCInternalOpenGLInternalFormat]; - GLenum format = tableFormats[tableFormatIndex_][kCCInternalOpenGLFormat]; - GLenum type = tableFormats[tableFormatIndex_][kCCInternalOpenGLType]; - BOOL compressed = tableFormats[tableFormatIndex_][kCCInternalCompressedImage]; + GLenum internalFormat = _pixelFormatInfo->internalFormat; + GLenum format = _pixelFormatInfo->format; + GLenum type = _pixelFormatInfo->type; + BOOL compressed = _pixelFormatInfo->compressed; // Generate textures with mipmaps for (GLint i=0; i < numberOfMipmaps_; i++) @@ -332,7 +524,7 @@ - (BOOL)createGLTexture } unsigned char *data = mipmaps_[i].address; - unsigned int datalen = mipmaps_[i].len; + GLsizei datalen = mipmaps_[i].len; if( compressed) glCompressedTexImage2D(GL_TEXTURE_2D, i, internalFormat, width, height, 0, datalen, data); @@ -384,12 +576,15 @@ - (id)initWithContentsOfFile:(NSString *)path name_ = 0; width_ = height_ = 0; - tableFormatIndex_ = -1; hasAlpha_ = FALSE; + _pixelFormatInfo = NULL; retainName_ = NO; // cocos2d integration - - if( ! [self unpackPVRData:pvrdata PVRLen:pvrlen] || ![self createGLTexture] ) { + + + if( ! (([self unpackPVRv2Data:pvrdata PVRLen:pvrlen] || [self unpackPVRv3Data:pvrdata PVRLen:pvrlen]) && + [self createGLTexture] ) ) + { free(pvrdata); [self release]; return nil; @@ -397,7 +592,7 @@ - (id)initWithContentsOfFile:(NSString *)path #if defined(__CC_PLATFORM_IOS) && defined(DEBUG) - GLenum pixelFormat = tableFormats[tableFormatIndex_][kCCInternalCCTexture2DPixelFormat]; + GLenum pixelFormat = _pixelFormatInfo->ccPixelFormat; CCConfiguration *conf = [CCConfiguration sharedConfiguration]; if( [conf OSVersion] >= kCCiOSVersion_5_0 ) diff --git a/vendor/Pods/cocos2d/cocos2d/CCTransition.h b/vendor/Pods/cocos2d/cocos2d/CCTransition.h index f57a949..ca1d74b 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCTransition.h +++ b/vendor/Pods/cocos2d/cocos2d/CCTransition.h @@ -91,6 +91,8 @@ typedef enum { */ @interface CCTransitionRotoZoom : CCTransitionScene {} +// needed for BrdigeSupport +-(id) init; @end /** CCTransitionJumpZoom: @@ -98,6 +100,8 @@ typedef enum { */ @interface CCTransitionJumpZoom : CCTransitionScene {} +// needed for BrdigeSupport +-(id) init; @end /** CCTransitionMoveInL: @@ -116,6 +120,8 @@ typedef enum { */ @interface CCTransitionMoveInR : CCTransitionMoveInL {} +// Needed for BridgeSupport +-(void) initScenes; @end /** CCTransitionMoveInT: @@ -123,6 +129,8 @@ typedef enum { */ @interface CCTransitionMoveInT : CCTransitionMoveInL {} +// Needed for BridgeSupport +-(void) initScenes; @end /** CCTransitionMoveInB: @@ -130,6 +138,8 @@ typedef enum { */ @interface CCTransitionMoveInB : CCTransitionMoveInL {} +// Needed for BridgeSupport +-(void) initScenes; @end /** CCTransitionSlideInL: @@ -148,6 +158,8 @@ typedef enum { */ @interface CCTransitionSlideInR : CCTransitionSlideInL {} +// Needed for BridgeSupport +-(void) initScenes; @end /** CCTransitionSlideInB: @@ -155,6 +167,8 @@ typedef enum { */ @interface CCTransitionSlideInB : CCTransitionSlideInL {} +// Needed for BridgeSupport +-(void) initScenes; @end /** CCTransitionSlideInT: @@ -162,6 +176,8 @@ typedef enum { */ @interface CCTransitionSlideInT : CCTransitionSlideInL {} +// Needed for BridgeSupport +-(void) initScenes; @end /** @@ -169,6 +185,8 @@ typedef enum { */ @interface CCTransitionShrinkGrow : CCTransitionScene {} +// needed for BrdigeSupport +-(id) init; @end /** CCTransitionFlipX: @@ -177,6 +195,8 @@ typedef enum { */ @interface CCTransitionFlipX : CCTransitionSceneOriented {} +// needed for BrdigeSupport +-(id) init; @end /** CCTransitionFlipY: @@ -185,6 +205,8 @@ typedef enum { */ @interface CCTransitionFlipY : CCTransitionSceneOriented {} +// needed for BrdigeSupport +-(id) init; @end /** CCTransitionFlipAngular: @@ -193,6 +215,8 @@ typedef enum { */ @interface CCTransitionFlipAngular : CCTransitionSceneOriented {} +// needed for BrdigeSupport +-(id) init; @end /** CCTransitionZoomFlipX: @@ -201,6 +225,8 @@ typedef enum { */ @interface CCTransitionZoomFlipX : CCTransitionSceneOriented {} +// needed for BrdigeSupport +-(id) init; @end /** CCTransitionZoomFlipY: @@ -209,6 +235,8 @@ typedef enum { */ @interface CCTransitionZoomFlipY : CCTransitionSceneOriented {} +// needed for BrdigeSupport +-(id) init; @end /** CCTransitionZoomFlipAngular: @@ -217,6 +245,8 @@ typedef enum { */ @interface CCTransitionZoomFlipAngular : CCTransitionSceneOriented {} +// needed for BrdigeSupport +-(id) init; @end /** CCTransitionFade: @@ -242,6 +272,8 @@ typedef enum { @class CCRenderTexture; @interface CCTransitionCrossFade : CCTransitionScene {} +// needed for BrdigeSupport +-(id) init; @end /** CCTransitionTurnOffTiles: @@ -249,6 +281,8 @@ typedef enum { */ @interface CCTransitionTurnOffTiles : CCTransitionScene {} +// needed for BrdigeSupport +-(id) init; @end /** CCTransitionSplitCols: @@ -264,6 +298,8 @@ typedef enum { */ @interface CCTransitionSplitRows : CCTransitionSplitCols {} +// Needed for BridgeSupport +-(CCActionInterval*) action; @end /** CCTransitionFadeTR: @@ -279,6 +315,7 @@ typedef enum { */ @interface CCTransitionFadeBL : CCTransitionFadeTR {} +-(CCActionInterval*) actionWithSize:(ccGridSize) vector; @end /** CCTransitionFadeUp: @@ -286,6 +323,7 @@ typedef enum { */ @interface CCTransitionFadeUp : CCTransitionFadeTR {} +-(CCActionInterval*) actionWithSize: (ccGridSize) v; @end /** CCTransitionFadeDown: @@ -293,4 +331,5 @@ typedef enum { */ @interface CCTransitionFadeDown : CCTransitionFadeTR {} +-(CCActionInterval*) actionWithSize: (ccGridSize) v; @end diff --git a/vendor/Pods/cocos2d/cocos2d/CCTransition.m b/vendor/Pods/cocos2d/cocos2d/CCTransition.m index f360a29..fd5e327 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCTransition.m +++ b/vendor/Pods/cocos2d/cocos2d/CCTransition.m @@ -216,6 +216,10 @@ -(id) initWithDuration:(ccTime) t scene:(CCScene*)s orientation:(tOrientation)o // RotoZoom // @implementation CCTransitionRotoZoom +-(id) init { + return [super init]; +} + -(void) onEnter { [super onEnter]; @@ -246,6 +250,9 @@ -(void) onEnter // JumpZoom // @implementation CCTransitionJumpZoom +-(id) init { + return [super init]; +} -(void) onEnter { [super onEnter]; @@ -465,6 +472,9 @@ -(CCActionInterval*) action // ShrinkGrow Transition // @implementation CCTransitionShrinkGrow +-(id) init { + return [super init]; +} -(void) onEnter { [super onEnter]; @@ -495,6 +505,9 @@ -(CCActionInterval*) easeActionWithAction:(CCActionInterval*)action // FlipX Transition // @implementation CCTransitionFlipX +-(id) init { + return [super init]; +} -(void) onEnter { [super onEnter]; @@ -539,6 +552,9 @@ -(void) onEnter // FlipY Transition // @implementation CCTransitionFlipY +-(id) init { + return [super init]; +} -(void) onEnter { [super onEnter]; @@ -582,6 +598,9 @@ -(void) onEnter // FlipAngular Transition // @implementation CCTransitionFlipAngular +-(id) init { + return [super init]; +} -(void) onEnter { [super onEnter]; @@ -624,6 +643,9 @@ -(void) onEnter // ZoomFlipX Transition // @implementation CCTransitionZoomFlipX +-(id) init { + return [super init]; +} -(void) onEnter { [super onEnter]; @@ -673,6 +695,9 @@ -(void) onEnter // ZoomFlipY Transition // @implementation CCTransitionZoomFlipY +-(id) init { + return [super init]; +} -(void) onEnter { [super onEnter]; @@ -723,6 +748,9 @@ -(void) onEnter // ZoomFlipAngular Transition // @implementation CCTransitionZoomFlipAngular +-(id) init { + return [super init]; +} -(void) onEnter { [super onEnter]; @@ -829,7 +857,9 @@ -(void) onExit // Cross Fade Transition // @implementation CCTransitionCrossFade - +-(id) init { + return [super init]; +} -(void) draw { // override draw since both scenes (textures) are rendered in 1 scene @@ -913,7 +943,9 @@ -(void) onExit // TurnOffTilesTransition // @implementation CCTransitionTurnOffTiles - +-(id) init { + return [super init]; +} // override addScenes, and change the order -(void) sceneOrder { diff --git a/vendor/Pods/cocos2d/cocos2d/CCTransitionProgress.h b/vendor/Pods/cocos2d/cocos2d/CCTransitionProgress.h index 241ff63..da43cdb 100644 --- a/vendor/Pods/cocos2d/cocos2d/CCTransitionProgress.h +++ b/vendor/Pods/cocos2d/cocos2d/CCTransitionProgress.h @@ -27,36 +27,58 @@ #import "CCTransition.h" +@class CCProgressTimer; + @interface CCTransitionProgress : CCTransitionScene { float to_, from_; CCScene *sceneToBeModified_; } +// Needed for BridgeSupport +-(CCProgressTimer*) progressTimerNodeWithRenderTexture:(CCRenderTexture*)texture; @end /** CCTransitionRadialCCW transition. A counter colock-wise radial transition to the next scene */ @interface CCTransitionProgressRadialCCW : CCTransitionProgress +{} +// Needed for BridgeSupport +-(CCProgressTimer*) progressTimerNodeWithRenderTexture:(CCRenderTexture*)texture; @end /** CCTransitionRadialCW transition. A counter colock-wise radial transition to the next scene */ @interface CCTransitionProgressRadialCW : CCTransitionProgress +{} +// Needed for BridgeSupport +-(CCProgressTimer*) progressTimerNodeWithRenderTexture:(CCRenderTexture*)texture; @end /** CCTransitionProgressHorizontal transition. A colock-wise radial transition to the next scene */ @interface CCTransitionProgressHorizontal : CCTransitionProgress +{} +// Needed for BridgeSupport +-(CCProgressTimer*) progressTimerNodeWithRenderTexture:(CCRenderTexture*)texture; @end @interface CCTransitionProgressVertical : CCTransitionProgress +{} +// Needed for BridgeSupport +-(CCProgressTimer*) progressTimerNodeWithRenderTexture:(CCRenderTexture*)texture; @end @interface CCTransitionProgressInOut : CCTransitionProgress +{} +// Needed for BridgeSupport +-(CCProgressTimer*) progressTimerNodeWithRenderTexture:(CCRenderTexture*)texture; @end @interface CCTransitionProgressOutIn : CCTransitionProgress +{} +// Needed for BridgeSupport +-(CCProgressTimer*) progressTimerNodeWithRenderTexture:(CCRenderTexture*)texture; @end diff --git a/vendor/Pods/cocos2d/cocos2d/Platforms/Mac/CCGLView.m b/vendor/Pods/cocos2d/cocos2d/Platforms/Mac/CCGLView.m index 62c2237..9453062 100644 --- a/vendor/Pods/cocos2d/cocos2d/Platforms/Mac/CCGLView.m +++ b/vendor/Pods/cocos2d/cocos2d/Platforms/Mac/CCGLView.m @@ -133,7 +133,10 @@ - (void) reshape [director reshapeProjection: NSSizeToCGSize(rect.size) ]; // avoid flicker - [director drawScene]; + // Only draw if there is something to draw, otherwise it actually creates a flicker of the current glClearColor + if(director.runningScene){ + [director drawScene]; + } // [self setNeedsDisplay:YES]; [self unlockOpenGLContext]; diff --git a/vendor/Pods/cocos2d/cocos2d/Platforms/iOS/CCDirectorIOS.h b/vendor/Pods/cocos2d/cocos2d/Platforms/iOS/CCDirectorIOS.h index 871b251..18f8d90 100644 --- a/vendor/Pods/cocos2d/cocos2d/Platforms/iOS/CCDirectorIOS.h +++ b/vendor/Pods/cocos2d/cocos2d/Platforms/iOS/CCDirectorIOS.h @@ -62,6 +62,9 @@ /** returns the content scale factor */ -(CGFloat) contentScaleFactor; + +/** converts a UITouch to a GL point */ +-(CGPoint)convertTouchToGL:(UITouch*)touch; @end #pragma mark - @@ -77,6 +80,10 @@ CCTouchDispatcher *touchDispatcher_; } + +// XXX: At least one method is needed for BridgeSupport +- (void) drawScene; + @end /** DisplayLinkDirector is a Director that synchronizes timers with the refresh rate of the display. diff --git a/vendor/Pods/cocos2d/cocos2d/Platforms/iOS/CCDirectorIOS.m b/vendor/Pods/cocos2d/cocos2d/Platforms/iOS/CCDirectorIOS.m index 22854f6..8e0ada2 100644 --- a/vendor/Pods/cocos2d/cocos2d/Platforms/iOS/CCDirectorIOS.m +++ b/vendor/Pods/cocos2d/cocos2d/Platforms/iOS/CCDirectorIOS.m @@ -236,6 +236,18 @@ -(void) setProjection:(ccDirectorProjection)projection ccSetProjectionMatrixDirty(); } +// override default logic +- (void)runWithScene:(CCScene*) scene +{ + NSAssert( scene != nil, @"Argument must be non-nil"); + NSAssert(runningScene_ == nil, @"This command can only be used to start the CCDirector. There is already a scene present."); + + [self pushScene:scene]; + + NSThread *thread = [self runningThread]; + [self performSelector:@selector(drawScene) onThread:thread withObject:nil waitUntilDone:YES]; +} + #pragma mark Director - TouchDispatcher -(CCTouchDispatcher*) touchDispatcher @@ -315,6 +327,9 @@ -(void) reshapeProjection:(CGSize)size winSizeInPixels_ = CGSizeMake(winSizeInPoints_.width * __ccContentScaleFactor, winSizeInPoints_.height *__ccContentScaleFactor); [self setProjection:projection_]; + + if( [delegate_ respondsToSelector:@selector(directorDidReshapeProjection:)] ) + [delegate_ directorDidReshapeProjection:self]; } #pragma mark Director Point Convertion @@ -327,6 +342,16 @@ -(CGPoint)convertToGL:(CGPoint)uiPoint return ccp( uiPoint.x, newY ); } +-(CGPoint)convertTouchToGL:(UITouch*)touch +{ + CGPoint uiPoint = [touch locationInView: [touch view]]; + CGSize s = winSizeInPoints_; + float newY = s.height - uiPoint.y; + + return ccp( uiPoint.x, newY ); +} + + -(CGPoint)convertToUI:(CGPoint)glPoint { CGSize winSize = winSizeInPoints_; diff --git a/vendor/Pods/cocos2d/cocos2d/Platforms/iOS/CCGLView.m b/vendor/Pods/cocos2d/cocos2d/Platforms/iOS/CCGLView.m index 3347c5e..cb3097c 100644 --- a/vendor/Pods/cocos2d/cocos2d/Platforms/iOS/CCGLView.m +++ b/vendor/Pods/cocos2d/cocos2d/Platforms/iOS/CCGLView.m @@ -223,8 +223,11 @@ - (void) layoutSubviews [director reshapeProjection:size_]; // Avoid flicker. Issue #350 - NSThread *thread = [director runningThread]; - [director performSelector:@selector(drawScene) onThread:thread withObject:nil waitUntilDone:YES]; + // Only draw if there is something to draw, otherwise it actually creates a flicker of the current glClearColor +// if(director.runningScene){ +// NSThread *thread = [director runningThread]; +// [director performSelector:@selector(drawScene) onThread:thread withObject:nil waitUntilDone:YES]; +// } } - (void) swapBuffers diff --git a/vendor/Pods/cocos2d/cocos2d/Support/CCFileUtils.h b/vendor/Pods/cocos2d/cocos2d/Support/CCFileUtils.h index 9cf7359..f6f2999 100644 --- a/vendor/Pods/cocos2d/cocos2d/Support/CCFileUtils.h +++ b/vendor/Pods/cocos2d/cocos2d/Support/CCFileUtils.h @@ -36,14 +36,16 @@ NSMutableDictionary *fullPathCache_; NSMutableDictionary *removeSuffixCache_; - -#ifdef __CC_PLATFORM_IOS BOOL enableFallbackSuffixes_; +#ifdef __CC_PLATFORM_IOS NSString *iPhoneRetinaDisplaySuffix_; NSString *iPadSuffix_; NSString *iPadRetinaDisplaySuffix_; -#endif // __CC_PLATFORM_IOS +#elif defined(__CC_PLATFORM_MAC) + NSString *macSuffix_; + NSString *macRetinaDisplaySuffix_; +#endif // __CC_PLATFORM_MAC } /** NSBundle used by CCFileUtils. By default it uses [NSBundle mainBundle]. @@ -56,6 +58,19 @@ */ @property (nonatomic, readwrite, retain) NSFileManager *fileManager; +/** Whether of not the fallback sufixes is enabled. + When enabled it will try to search for the following suffixes in the following order until one is found: + * On iPad HD : iPad HD suffix, iPad suffix, iPhone HD suffix, Without suffix + * On iPad : iPad suffix, iPhone HD suffix, Without suffix + * On iPhone HD: iPhone HD suffix, Without suffix + * On Mac HD : Mac HD suffix, Mac suffix, Without suffix + * On Mac : Mac suffix, Without suffix + + By default this functionality is off; + */ +@property (nonatomic, readwrite) BOOL enableFallbackSuffixes; + + #ifdef __CC_PLATFORM_IOS /** The iPhone RetinaDisplay suffixes to load resources. By default it is "-hd" and "" in that order. @@ -82,17 +97,25 @@ */ @property (nonatomic,readwrite, copy, setter = setiPadRetinaDisplaySuffix:) NSString *iPadRetinaDisplaySuffix; -/** Whether of not the fallback sufixes is enabled. - When enabled it will try to search for the following suffixes in the following order until one is found: - * On iPad HD : iPad HD suffix, iPad suffix, iPhone HD suffix, Without suffix - * On iPad : iPad suffix, iPhone HD suffix, Without suffix - * On iPhone HD: iPhone HD suffix, Without suffix +#elif defined(__CC_PLATFORM_MAC) +/** The Mac suffixes to load resources. + By default it is "-mac", "" in that order. + Only valid on OS X. Not valid for iOS. - By default this functionality is off; -*/ -@property (nonatomic, readwrite) BOOL enableFallbackSuffixes; + @since v2.1 + */ +@property (nonatomic,readwrite, copy, setter = setMacSuffix:) NSString *macSuffix; + +/** The Mac Retina Display suffixes to load resources. + By default it is "-machd", "-mac", "" in that order. + Only valid on OS X. Not valid for iOS. + + @since v2.1 + */ +@property (nonatomic,readwrite, copy, setter = setMacRetinaDisplaySuffix:) NSString *macRetinaDisplaySuffix; + +#endif // __CC_PLATFORM_MAC - #endif // __CC_PLATFORM_IOS /** returns the shared file utils instance */ +(CCFileUtils*) sharedFileUtils; @@ -128,6 +151,7 @@ * In iPad mode: "image.png" -> "/full/path/image-ipad.png" (in case the -ipad file exists) * In iPhone RetinaDisplay mode: "image.png" -> "/full/path/image-hd.png" (in case the -hd file exists) * In iPad RetinaDisplay mode: "image.png" -> "/full/path/image-ipadhd.png" (in case the -ipadhd file exists) + * In Mac RetinaDisplay mode: "image.png" -> "/full/path/image-hd.png" (in case the -hd file exists) If an iPad file is found, it will set resolution type to kCCResolutioniPad If a RetinaDisplay file is found, it will set resolution type to kCCResolutionRetinaDisplay @@ -166,10 +190,24 @@ */ -(BOOL) iPadRetinaDisplayFileExistsAtPath:(NSString*)filename; -#endif // __CC_PLATFORM_IOS +#elif defined(__CC_PLATFORM_MAC) -@end +/** Returns whether or not a given filename exists with the Mac RetinaDisplay suffix. + Only available on OS X. Not supported on iOS + @since v2.1 + */ +-(BOOL) macRetinaDisplayFileExistsAtPath:(NSString*)filename; +/** Returns whether or not a given filename exists with the Mac RetinaDisplay suffix. + Only available on OS X. Not supported on iOS + @since v2.1 + */ +-(BOOL) macFileExistsAtPath:(NSString*)filename; + +#endif // __CC_PLATFORM_MAC + + +@end #ifdef __cplusplus extern "C" { @@ -182,7 +220,7 @@ extern "C" { @since v0.99.5 */ NSInteger ccLoadFileIntoMemory(const char *filename, unsigned char **out); - + #ifdef __cplusplus } #endif diff --git a/vendor/Pods/cocos2d/cocos2d/Support/CCFileUtils.m b/vendor/Pods/cocos2d/cocos2d/Support/CCFileUtils.m index 97c4a94..b372d3f 100644 --- a/vendor/Pods/cocos2d/cocos2d/Support/CCFileUtils.m +++ b/vendor/Pods/cocos2d/cocos2d/Support/CCFileUtils.m @@ -31,12 +31,19 @@ #import "../ccConfig.h" #import "../ccTypes.h" +#ifdef __CC_PLATFORM_IOS enum { kCCiPhone, kCCiPhoneRetinaDisplay, kCCiPad, kCCiPadRetinaDisplay, }; +#elif __CC_PLATFORM_MAC +enum { + kCCMac, + kCCMacRetinaDisplay, +}; +#endif #pragma mark - Helper free functions @@ -103,22 +110,24 @@ - (void)dealloc #pragma mark - CCFileUtils -#ifdef __CC_PLATFORM_IOS @interface CCFileUtils() -(NSString *) removeSuffix:(NSString*)suffix fromPath:(NSString*)path; -(BOOL) fileExistsAtPath:(NSString*)string withSuffix:(NSString*)suffix; -(NSInteger) runningDevice; @end -#endif // __CC_PLATFORM_IOS @implementation CCFileUtils @synthesize fileManager=fileManager_, bundle=bundle_; +@synthesize enableFallbackSuffixes = enableFallbackSuffixes_; + #ifdef __CC_PLATFORM_IOS @synthesize iPhoneRetinaDisplaySuffix = iPhoneRetinaDisplaySuffix_; @synthesize iPadSuffix = iPadSuffix_; @synthesize iPadRetinaDisplaySuffix = iPadRetinaDisplaySuffix_; -@synthesize enableFallbackSuffixes = enableFallbackSuffixes_; +#elif defined(__CC_PLATFORM_MAC) +@synthesize macSuffix = macSuffix_; +@synthesize macRetinaDisplaySuffix = macRetinaDisplaySuffix_; #endif // __CC_PLATFORM_IOS + (id)sharedFileUtils @@ -141,12 +150,15 @@ -(id) init bundle_ = [[NSBundle mainBundle] retain]; + enableFallbackSuffixes_ = NO; + #ifdef __CC_PLATFORM_IOS iPhoneRetinaDisplaySuffix_ = @"-hd"; iPadSuffix_ = @"-ipad"; - iPadRetinaDisplaySuffix_ = @"-ipadhd"; - - enableFallbackSuffixes_ = NO; + iPadRetinaDisplaySuffix_ = @"-ipadhd"; +#elif defined(__CC_PLATFORM_MAC) + macRetinaDisplaySuffix_ = @"-machd"; + macSuffix_ = @"-mac"; #endif // __CC_PLATFORM_IOS } @@ -171,7 +183,12 @@ - (void)dealloc [iPhoneRetinaDisplaySuffix_ release]; [iPadSuffix_ release]; [iPadRetinaDisplaySuffix_ release]; -#endif // __CC_PLATFORM_IOS + +#elif defined(__CC_PLATFORM_MAC) + [macRetinaDisplaySuffix_ release]; + [macSuffix_ release]; + +#endif // __CC_PLATFORM_MAC [super dealloc]; } @@ -248,10 +265,10 @@ -(NSString*) fullPathFromRelativePath:(NSString*)relPath resolutionType:(ccResol // Initialize to non-nil NSString *ret = @""; -#ifdef __CC_PLATFORM_IOS - NSInteger device = [self runningDevice]; +#ifdef __CC_PLATFORM_IOS + // iPad HD ? if( device == kCCiPadRetinaDisplay ) { ret = [self getPath:relPath forSuffix:iPadRetinaDisplaySuffix_]; @@ -279,9 +296,22 @@ -(NSString*) fullPathFromRelativePath:(NSString*)relPath resolutionType:(ccResol #elif defined(__CC_PLATFORM_MAC) - *resolutionType = kCCResolutionMac; + if( device == kCCMacRetinaDisplay ) { + ret = [self getPath:relPath forSuffix:macRetinaDisplaySuffix_]; + *resolutionType = kCCResolutionMacRetinaDisplay; + } + + if( device == kCCMac || (enableFallbackSuffixes_ && !ret) ) { + ret = [self getPath:relPath forSuffix:macSuffix_]; + *resolutionType = kCCResolutionMac; + } - ret = [self getPath:relPath forSuffix:@""]; + // Not found ? Try with empty "" suffix. + if( !ret ) + { + ret = [self getPath:relPath forSuffix:@""]; + *resolutionType = kCCResolutionMac; + } #endif // __CC_PLATFORM_MAC @@ -303,15 +333,15 @@ -(NSString*) fullPathFromRelativePath:(NSString*) relPath return [self fullPathFromRelativePath:relPath resolutionType:&ignore]; } -#pragma mark CCFileUtils - Suffix (iOS only) - -#ifdef __CC_PLATFORM_IOS +#pragma mark CCFileUtils - Suffix // XXX: Optimization: This should be called only once -(NSInteger) runningDevice { NSInteger ret=-1; +#ifdef __CC_PLATFORM_IOS + if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { if( CC_CONTENT_SCALE_FACTOR() == 2 ) @@ -326,6 +356,13 @@ -(NSInteger) runningDevice else ret = kCCiPhone; } + +#elif defined(__CC_PLATFORM_MAC) + + // XXX: Add here support for Mac Retina Display + ret = kCCMac; + +#endif // __CC_PLATFORM_MAC return ret; } @@ -335,20 +372,20 @@ -(NSString *) removeSuffix:(NSString*)suffix fromPath:(NSString*)path // quick return if( ! suffix || [suffix length] == 0 ) return path; - + NSString *name = [path lastPathComponent]; - + // check if path already has the suffix. if( [name rangeOfString:suffix].location != NSNotFound ) { - + CCLOGINFO(@"cocos2d: Filename(%@) contains %@ suffix. Removing it. See cocos2d issue #1040", path, suffix); - + NSString *newLastname = [name stringByReplacingOccurrencesOfString:suffix withString:@""]; - + NSString *pathWithoutLastname = [path stringByDeletingLastPathComponent]; return [pathWithoutLastname stringByAppendingPathComponent:newLastname]; } - + // suffix was not removed return nil; } @@ -358,24 +395,34 @@ -(NSString*) removeSuffixFromFile:(NSString*) path NSString *withoutSuffix = [removeSuffixCache_ objectForKey:path]; if( withoutSuffix ) return withoutSuffix; - + // Initial value should be non-nil NSString *ret = @""; - + NSInteger device = [self runningDevice]; +#ifdef __CC_PLATFORM_IOS if( device == kCCiPadRetinaDisplay ) ret = [self removeSuffix:iPadRetinaDisplaySuffix_ fromPath:path]; if( device == kCCiPad || (enableFallbackSuffixes_ && !ret) ) - ret = [self removeSuffix:iPadSuffix_ fromPath:path]; - + ret = [self removeSuffix:iPadSuffix_ fromPath:path]; + if( device == kCCiPhoneRetinaDisplay || (enableFallbackSuffixes_ && !ret) ) ret = [self removeSuffix:iPhoneRetinaDisplaySuffix_ fromPath:path]; - + if( device == kCCiPhone || !ret ) ret = path; +#elif defined(__CC_PLATFORM_MAC) + if( device == kCCMacRetinaDisplay ) + ret = [self removeSuffix:macRetinaDisplaySuffix_ fromPath:path]; + + if( device == kCCMac|| !ret ) + ret = [self removeSuffix:macSuffix_ fromPath:path]; + +#endif // __CC_PLATFORM_MAC + if( ret ) [removeSuffixCache_ setObject:ret forKey:path]; @@ -385,27 +432,29 @@ -(NSString*) removeSuffixFromFile:(NSString*) path -(BOOL) fileExistsAtPath:(NSString*)relPath withSuffix:(NSString*)suffix { NSString *fullpath = nil; - + // only if it is not an absolute path if( ! [relPath isAbsolutePath] ) { // pathForResource also searches in .lproj directories. issue #1230 NSString *file = [relPath lastPathComponent]; NSString *imageDirectory = [relPath stringByDeletingLastPathComponent]; - + fullpath = [bundle_ pathForResource:file - ofType:nil - inDirectory:imageDirectory]; - + ofType:nil + inDirectory:imageDirectory]; + } - + if (fullpath == nil) fullpath = relPath; - + NSString *path = [self getPath:fullpath forSuffix:suffix]; - + return ( path != nil ); } +#ifdef __CC_PLATFORM_IOS + -(BOOL) iPhoneRetinaDisplayFileExistsAtPath:(NSString*)path { return [self fileExistsAtPath:path withSuffix:iPhoneRetinaDisplaySuffix_]; @@ -421,7 +470,19 @@ -(BOOL) iPadRetinaDisplayFileExistsAtPath:(NSString*)path return [self fileExistsAtPath:path withSuffix:iPadRetinaDisplaySuffix_]; } -#endif // __CC_PLATFORM_IOS +#elif defined(__CC_PLATFORM_MAC) + +-(BOOL) macRetinaDisplayFileExistsAtPath:(NSString*)path +{ + return [self fileExistsAtPath:path withSuffix:macRetinaDisplaySuffix_]; +} + +-(BOOL) macFileExistsAtPath:(NSString*)path +{ + return [self fileExistsAtPath:path withSuffix:macSuffix_]; +} + +#endif // __CC_PLATFORM_MAC @end diff --git a/vendor/Pods/cocos2d/cocos2d/Support/CGPointExtension.h b/vendor/Pods/cocos2d/cocos2d/Support/CGPointExtension.h index 90510c4..ff92362 100644 --- a/vendor/Pods/cocos2d/cocos2d/Support/CGPointExtension.h +++ b/vendor/Pods/cocos2d/cocos2d/Support/CGPointExtension.h @@ -63,8 +63,10 @@ extern "C" { @return CGPoint @since v0.7.2 */ -#define ccp(__X__,__Y__) CGPointMake(__X__,__Y__) - +static inline CGPoint ccp( CGFloat x, CGFloat y ) +{ + return CGPointMake(x, y); +} /** Returns opposite of point. @return CGPoint diff --git a/vendor/Pods/cocos2d/cocos2d/ccDeprecated.h b/vendor/Pods/cocos2d/cocos2d/ccDeprecated.h index 0b16933..a4cf5a7 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccDeprecated.h +++ b/vendor/Pods/cocos2d/cocos2d/ccDeprecated.h @@ -285,6 +285,12 @@ DEPRECATED_ATTRIBUTE @interface MacView : CCGLView + (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size DEPRECATED_ATTRIBUTE; // new: + (id) labelWithString:(NSString*)string dimensions:hAlignment:lineBreakMode:fontName:fontSize: + (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size DEPRECATED_ATTRIBUTE; + ++ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size DEPRECATED_ATTRIBUTE; ++ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size DEPRECATED_ATTRIBUTE; ++ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment)vertAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size DEPRECATED_ATTRIBUTE; ++ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment)vertAlignment fontName:(NSString*)name fontSize:(CGFloat)size DEPRECATED_ATTRIBUTE; + // new: + (id) initWithString:(NSString*)string dimensions:hAlignment:fontName:fontSize: - (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size DEPRECATED_ATTRIBUTE; // new: + (id) initWithString:(NSString*)string dimensions:hAlignment:lineBreakMode:fontName:fontSize: diff --git a/vendor/Pods/cocos2d/cocos2d/ccDeprecated.m b/vendor/Pods/cocos2d/cocos2d/ccDeprecated.m index 34b0645..3acd42d 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccDeprecated.m +++ b/vendor/Pods/cocos2d/cocos2d/ccDeprecated.m @@ -31,7 +31,7 @@ // Free functions void ccGLUniformModelViewProjectionMatrix( CCGLProgram* program ) { - [program setUniformForModelViewProjectionMatrix]; + [program setUniformsForBuiltins]; } @implementation CCScheduler (Deprecated) @@ -381,30 +381,48 @@ -(void) addSpriteFramesWithFile:(NSString*)plist textureFile:(NSString*)filename @implementation CCLabelTTF (Deprecated) + (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size { - return [self labelWithString:string dimensions:dimensions hAlignment:alignment fontName:name fontSize:size]; + return [self labelWithString:string fontName:name fontSize:size dimensions:dimensions hAlignment:alignment]; } + (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size { - return [self labelWithString:string dimensions:dimensions hAlignment:alignment lineBreakMode:lineBreakMode fontName:name fontSize:size]; + return [self labelWithString:string fontName:name fontSize:size dimensions:dimensions hAlignment:alignment lineBreakMode:lineBreakMode]; } ++ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size +{ + return [self labelWithString:string fontName:name fontSize:size dimensions:dimensions hAlignment:alignment]; +} ++ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size +{ + return [self labelWithString:string fontName:name fontSize:size dimensions:dimensions hAlignment:alignment lineBreakMode:lineBreakMode]; +} ++ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment)vertAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size +{ + return [self labelWithString:string fontName:name fontSize:size dimensions:dimensions hAlignment:alignment vAlignment:vertAlignment lineBreakMode:lineBreakMode]; +} + ++ (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment)vertAlignment fontName:(NSString*)name fontSize:(CGFloat)size +{ + return [self labelWithString:string fontName:name fontSize:size dimensions:dimensions hAlignment:alignment vAlignment:vertAlignment]; +} + - (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size { - return [self initWithString:string dimensions:dimensions hAlignment:alignment fontName:name fontSize:size]; + return [self initWithString:string fontName:name fontSize:size dimensions:dimensions hAlignment:alignment]; } - (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size { - return [self initWithString:string dimensions:dimensions hAlignment:alignment lineBreakMode:lineBreakMode fontName:name fontSize:size]; + return [self initWithString:string fontName:name fontSize:size dimensions:dimensions hAlignment:alignment lineBreakMode:lineBreakMode]; } @end @implementation CCTexture2D (Deprecated) - (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size { - return [self initWithString:string dimensions:dimensions hAlignment:alignment vAlignment:kCCVerticalTextAlignmentTop lineBreakMode:lineBreakMode fontName:name fontSize:size]; + return [self initWithString:string fontName:name fontSize:size dimensions:dimensions hAlignment:alignment vAlignment:kCCVerticalTextAlignmentTop lineBreakMode:lineBreakMode ]; } - (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size { - return [self initWithString:string dimensions:dimensions hAlignment:alignment vAlignment:kCCVerticalTextAlignmentTop fontName:name fontSize:size]; + return [self initWithString:string fontName:name fontSize:size dimensions:dimensions hAlignment:alignment vAlignment:kCCVerticalTextAlignmentTop ]; } @end diff --git a/vendor/Pods/cocos2d/cocos2d/ccGLStateCache.h b/vendor/Pods/cocos2d/cocos2d/ccGLStateCache.h index 1356829..38e9ee1 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccGLStateCache.h +++ b/vendor/Pods/cocos2d/cocos2d/ccGLStateCache.h @@ -45,11 +45,12 @@ typedef enum { // CC_GL_SCISSOR_TEST = 1 << 0, // CC_GL_STENCIL_TEST = 1 << 1, // CC_GL_DEPTH_TEST = 1 << 2, - CC_GL_BLEND = 1 << 3, +// CC_GL_BLEND = 1 << 3, // CC_GL_DITHER = 1 << 4, // CC_GL_ALL = ( CC_GL_SCISSOR_TEST | CC_GL_STENCIL_TEST | CC_GL_DEPTH_TEST | CC_GL_BLEND | CC_GL_DITHER ), - CC_GL_ALL = ( CC_GL_BLEND ), +// CC_GL_ALL = ( CC_GL_BLEND ), + CC_GL_ALL = 0, } ccGLServerState; @@ -84,6 +85,12 @@ void ccGLDeleteProgram( GLuint program ); */ void ccGLBlendFunc(GLenum sfactor, GLenum dfactor); +/** Resets the blending mode back to the cached state in case you used glBlendFuncSeparate() or glBlendEquation(). + If CC_ENABLE_GL_STATE_CACHE is disabled, it will just set the default blending mode using GL_FUNC_ADD. + @since v2.0.0 + */ +void ccGLBlendResetToCache(void); + /** sets the projection matrix as dirty @since v2.0.0 */ @@ -102,24 +109,17 @@ void ccSetProjectionMatrixDirty( void ); */ void ccGLEnableVertexAttribs( unsigned int flags ); -/** If the active texture is not textureEnum, then it will active it. - If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glActiveTexture() directly. - @since v2.0.0 - */ -void ccGLActiveTexture(GLenum textureEnum ); - -/** Returns the active texture. - If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glGetIntegerv(GL_ACTIVE_TEXTURE); +/** If the texture is not already bound to texture unit 0, it binds it. + If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly. @since v2.0.0 */ -GLenum ccGLGetActiveTexture( void ); - +void ccGLBindTexture2D( GLuint textureId ); -/** If the texture is not already bound, it binds it. +/** If the texture is not already bound to a given unit, it binds it. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly. @since v2.0.0 */ -void ccGLBindTexture2D(GLuint textureId ); +void ccGLBindTexture2DN( GLuint textureUnit, GLuint textureId ); /** It will delete a given texture. If the texture was bound, it will invalidate the cached. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glDeleteTextures() directly. @@ -127,6 +127,12 @@ void ccGLBindTexture2D(GLuint textureId ); */ void ccGLDeleteTexture(GLuint textureId); +/** If the vertex array is not already bound, it binds it. + If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindVertexArray() directly. + @since v2.0.0 + */ +void ccGLBindVAO(GLuint vaoId); + /** It will enable / disable the server side GL states. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glEnable() directly. @since v2.0.0 diff --git a/vendor/Pods/cocos2d/cocos2d/ccGLStateCache.m b/vendor/Pods/cocos2d/cocos2d/ccGLStateCache.m index 0918db0..3105eb3 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccGLStateCache.m +++ b/vendor/Pods/cocos2d/cocos2d/ccGLStateCache.m @@ -41,10 +41,10 @@ #define kCCMaxActiveTexture 16 static GLuint _ccCurrentShaderProgram = -1; static GLuint _ccCurrentBoundTexture[kCCMaxActiveTexture] = {-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, }; -static GLenum _ccCurrentActiveTexture = (GL_TEXTURE0 - GL_TEXTURE0); static GLenum _ccBlendingSource = -1; static GLenum _ccBlendingDest = -1; static ccGLServerState _ccGLServerState = 0; +static GLuint _ccVAO = 0; #endif // CC_ENABLE_GL_STATE_CACHE #pragma mark - GL State Cache functions @@ -62,7 +62,6 @@ void ccGLInvalidateStateCache( void ) _ccCurrentShaderProgram = -1; for( NSInteger i=0; i < kCCMaxActiveTexture; i++ ) _ccCurrentBoundTexture[i] = -1; - _ccCurrentActiveTexture = (GL_TEXTURE0 - GL_TEXTURE0); _ccBlendingSource = -1; _ccBlendingDest = -1; _ccGLServerState = 0; @@ -91,6 +90,15 @@ void ccGLUseProgram( GLuint program ) #endif // CC_ENABLE_GL_STATE_CACHE } +static void SetBlending(GLenum sfactor, GLenum dfactor) +{ + if(sfactor == GL_ONE && dfactor == GL_ZERO){ + glDisable(GL_BLEND); + } else { + glEnable(GL_BLEND); + glBlendFunc( sfactor, dfactor ); + } +} void ccGLBlendFunc(GLenum sfactor, GLenum dfactor) { @@ -98,83 +106,87 @@ void ccGLBlendFunc(GLenum sfactor, GLenum dfactor) if( sfactor != _ccBlendingSource || dfactor != _ccBlendingDest ) { _ccBlendingSource = sfactor; _ccBlendingDest = dfactor; - glBlendFunc( sfactor, dfactor ); + SetBlending( sfactor, dfactor ); } #else - glBlendFunc( sfactor, dfactor ); + SetBlending( sfactor, dfactor ); #endif // CC_ENABLE_GL_STATE_CACHE } -GLenum ccGLGetActiveTexture( void ) +void ccGLBlendResetToCache(void) { + glBlendEquation(GL_FUNC_ADD); #if CC_ENABLE_GL_STATE_CACHE - return _ccCurrentActiveTexture + GL_TEXTURE0; + SetBlending( _ccBlendingSource, _ccBlendingDest ); #else - GLenum activeTexture; - glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&activeTexture); - return activeTexture; -#endif + SetBlending( CC_BLEND_SRC, CC_BLEND_DST ); +#endif // CC_ENABLE_GL_STATE_CACHE } -void ccGLActiveTexture( GLenum textureEnum ) +void ccGLBindTexture2D( GLuint textureId ) { -#if CC_ENABLE_GL_STATE_CACHE - NSCAssert1( (textureEnum - GL_TEXTURE0) < kCCMaxActiveTexture, @"cocos2d ERROR: Increase kCCMaxActiveTexture to %d!", (textureEnum-GL_TEXTURE0) ); - if( (textureEnum - GL_TEXTURE0) != _ccCurrentActiveTexture ) { - _ccCurrentActiveTexture = (textureEnum - GL_TEXTURE0); - glActiveTexture( textureEnum ); - } -#else - glActiveTexture( textureEnum ); -#endif + ccGLBindTexture2DN(0, textureId); } -void ccGLBindTexture2D( GLuint textureId ) + +void ccGLBindTexture2DN( GLuint textureUnit, GLuint textureId ) { #if CC_ENABLE_GL_STATE_CACHE - if( _ccCurrentBoundTexture[ _ccCurrentActiveTexture ] != textureId ) + NSCAssert1( textureUnit < kCCMaxActiveTexture, @"cocos2d ERROR: Increase kCCMaxActiveTexture to %d!", textureUnit - GL_TEXTURE0); + if( _ccCurrentBoundTexture[ textureUnit ] != textureId ) { - _ccCurrentBoundTexture[ _ccCurrentActiveTexture ] = textureId; + _ccCurrentBoundTexture[ textureUnit ] = textureId; + glActiveTexture( GL_TEXTURE0 + textureUnit ); glBindTexture(GL_TEXTURE_2D, textureId ); } #else + glActiveTexture( GL_TEXTURE0 + textureUnit ); glBindTexture(GL_TEXTURE_2D, textureId ); #endif } void ccGLDeleteTexture( GLuint textureId ) +{ + glDeleteTextures(1, &textureId ); +} + +void ccGLBindVAO(GLuint vaoId) { #if CC_ENABLE_GL_STATE_CACHE - if( textureId == _ccCurrentBoundTexture[ _ccCurrentActiveTexture ] ) - _ccCurrentBoundTexture[ _ccCurrentActiveTexture ] = -1; + if( _ccVAO != vaoId ) + { + _ccVAO = vaoId; + glBindVertexArray(vaoId); + } +#else + glBindVertexArray(vaoId); #endif - glDeleteTextures(1, &textureId ); } void ccGLEnable( ccGLServerState flags ) { #if CC_ENABLE_GL_STATE_CACHE - BOOL enabled = NO; - - /* GL_BLEND */ - if( (enabled=(flags & CC_GL_BLEND)) != (_ccGLServerState & CC_GL_BLEND) ) { - if( enabled ) { - glEnable( GL_BLEND ); - _ccGLServerState |= CC_GL_BLEND; - } else { - glDisable( GL_BLEND ); - _ccGLServerState &= ~CC_GL_BLEND; - } - } +// BOOL enabled = NO; +// +// /* GL_BLEND */ +// if( (enabled=(flags & CC_GL_BLEND)) != (_ccGLServerState & CC_GL_BLEND) ) { +// if( enabled ) { +// glEnable( GL_BLEND ); +// _ccGLServerState |= CC_GL_BLEND; +// } else { +// glDisable( GL_BLEND ); +// _ccGLServerState &= ~CC_GL_BLEND; +// } +// } #else - if( flags & CC_GL_BLEND ) - glEnable( GL_BLEND ); - else - glDisable( GL_BLEND ); +// if( flags & CC_GL_BLEND ) +// glEnable( GL_BLEND ); +// else +// glDisable( GL_BLEND ); #endif } @@ -182,6 +194,8 @@ void ccGLEnable( ccGLServerState flags ) void ccGLEnableVertexAttribs( unsigned int flags ) { + ccGLBindVAO(0); + /* Position */ BOOL enablePosition = flags & kCCVertexAttribFlag_Position; diff --git a/vendor/Pods/cocos2d/cocos2d/ccMacros.h b/vendor/Pods/cocos2d/cocos2d/ccMacros.h index 93032f4..54ecd88 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccMacros.h +++ b/vendor/Pods/cocos2d/cocos2d/ccMacros.h @@ -191,7 +191,7 @@ do { \ ccGLEnable( glServerState_ ); \ NSAssert1(shaderProgram_, @"No shader program set for node: %@", self); \ [shaderProgram_ use]; \ - [shaderProgram_ setUniformForModelViewProjectionMatrix]; \ + [shaderProgram_ setUniformsForBuiltins]; \ } while(0) diff --git a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionColorLengthTexture_frag.h b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionColorLengthTexture_frag.h new file mode 100644 index 0000000..80470e2 --- /dev/null +++ b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionColorLengthTexture_frag.h @@ -0,0 +1,41 @@ +/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +" \n\ +#extension GL_OES_standard_derivatives : enable \n\ + \n\ +#ifdef GL_ES \n\ +varying mediump vec4 v_color; \n\ +varying mediump vec2 v_texcoord; \n\ +#else \n\ +varying vec4 v_color; \n\ +varying vec2 v_texcoord; \n\ +#endif \n\ + \n\ +void main() \n\ +{ \n\ +#if defined GL_OES_standard_derivatives \n\ + gl_FragColor = v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord)); \n\ +#else \n\ + gl_FragColor = v_color*step(0.0, 1.0 - length(v_texcoord)); \n\ +#endif \n\ +} \n\ +"; diff --git a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionColorLengthTexture_vert.h b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionColorLengthTexture_vert.h new file mode 100644 index 0000000..3a8e96d --- /dev/null +++ b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionColorLengthTexture_vert.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +" \n\ +#ifdef GL_ES \n\ +attribute mediump vec4 a_position; \n\ +attribute mediump vec2 a_texcoord; \n\ +attribute mediump vec4 a_color; \n\ + \n\ +varying mediump vec4 v_color; \n\ +varying mediump vec2 v_texcoord; \n\ + \n\ +#else \n\ +attribute vec4 a_position; \n\ +attribute vec2 a_texcoord; \n\ +attribute vec4 a_color; \n\ + \n\ +varying vec4 v_color; \n\ +varying vec2 v_texcoord; \n\ +#endif \n\ + \n\ +void main() \n\ +{ \n\ + v_color = vec4(a_color.rgb * a_color.a, a_color.a); \n\ + v_texcoord = a_texcoord; \n\ + \n\ + gl_Position = CC_MVPMatrix * a_position; \n\ +} \n\ +"; diff --git a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionColor_frag.h b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionColor_frag.h index 2c28489..910903d 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionColor_frag.h +++ b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionColor_frag.h @@ -1,3 +1,28 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ diff --git a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionColor_vert.h b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionColor_vert.h index 815e161..633f338 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionColor_vert.h +++ b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionColor_vert.h @@ -1,8 +1,31 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + " \n\ attribute vec4 a_position; \n\ attribute vec4 a_color; \n\ -uniform mat4 u_MVPMatrix; \n\ - \n\ #ifdef GL_ES \n\ varying lowp vec4 v_fragmentColor; \n\ #else \n\ @@ -11,7 +34,7 @@ varying vec4 v_fragmentColor; \n\ \n\ void main() \n\ { \n\ - gl_Position = u_MVPMatrix * a_position; \n\ + gl_Position = CC_MVPMatrix * a_position; \n\ v_fragmentColor = a_color; \n\ } \n\ "; diff --git a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureA8Color_frag.h b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureA8Color_frag.h index 0b6cd10..6a8fb85 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureA8Color_frag.h +++ b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureA8Color_frag.h @@ -1,3 +1,28 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ @@ -5,12 +30,12 @@ precision lowp float; \n\ \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ -uniform sampler2D u_texture; \n\ +uniform sampler2D CC_Texture0; \n\ \n\ void main() \n\ { \n\ gl_FragColor = vec4( v_fragmentColor.rgb, // RGB from uniform \n\ - v_fragmentColor.a * texture2D(u_texture, v_texCoord).a // A from texture & uniform \n\ + v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a // A from texture & uniform \n\ ); \n\ } \n\ "; diff --git a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureA8Color_vert.h b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureA8Color_vert.h index b844932..bb29e7d 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureA8Color_vert.h +++ b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureA8Color_vert.h @@ -1,8 +1,32 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + " \n\ attribute vec4 a_position; \n\ attribute vec2 a_texCoord; \n\ attribute vec4 a_color; \n\ -uniform mat4 u_MVPMatrix; \n\ \n\ #ifdef GL_ES \n\ varying lowp vec4 v_fragmentColor; \n\ @@ -14,7 +38,7 @@ varying vec2 v_texCoord; \n\ \n\ void main() \n\ { \n\ - gl_Position = u_MVPMatrix * a_position; \n\ + gl_Position = CC_MVPMatrix * a_position; \n\ v_fragmentColor = a_color; \n\ v_texCoord = a_texCoord; \n\ } \n\ diff --git a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureColorAlphaTest_frag.h b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureColorAlphaTest_frag.h index 253c5e8..fe321ba 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureColorAlphaTest_frag.h +++ b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureColorAlphaTest_frag.h @@ -1,3 +1,27 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Brian Chapados + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ @@ -5,17 +29,17 @@ precision lowp float; \n\ \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ -uniform sampler2D u_texture; \n\ -uniform float u_alpha_value; \n\ +uniform sampler2D CC_Texture0; \n\ +uniform float CC_alpha_value; \n\ \n\ void main() \n\ { \n\ - vec4 texColor = texture2D(u_texture, v_texCoord); \n\ + vec4 texColor = texture2D(CC_Texture0, v_texCoord); \n\ \n\ // mimic: glAlphaFunc(GL_GREATER) \n\ - // pass if ( incoming_pixel >= u_alpha_value ) => fail if incoming_pixel < u_alpha_value \n\ + // pass if ( incoming_pixel >= CC_alpha_value ) => fail if incoming_pixel < CC_alpha_value \n\ \n\ - if ( texColor.a <= u_alpha_value ) \n\ + if ( texColor.a <= CC_alpha_value ) \n\ discard; \n\ \n\ gl_FragColor = texColor * v_fragmentColor; \n\ diff --git a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureColor_frag.h b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureColor_frag.h index aba7e21..df5527e 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureColor_frag.h +++ b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureColor_frag.h @@ -1,3 +1,28 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ @@ -5,10 +30,10 @@ precision lowp float; \n\ \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ -uniform sampler2D u_texture; \n\ +uniform sampler2D CC_Texture0; \n\ \n\ void main() \n\ { \n\ - gl_FragColor = v_fragmentColor * texture2D(u_texture, v_texCoord); \n\ + gl_FragColor = v_fragmentColor * texture2D(CC_Texture0, v_texCoord); \n\ } \n\ "; diff --git a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureColor_vert.h b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureColor_vert.h index cf2361d..bb29e7d 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureColor_vert.h +++ b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTextureColor_vert.h @@ -1,10 +1,33 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + " \n\ attribute vec4 a_position; \n\ attribute vec2 a_texCoord; \n\ attribute vec4 a_color; \n\ \n\ -uniform mat4 u_MVPMatrix; \n\ - \n\ #ifdef GL_ES \n\ varying lowp vec4 v_fragmentColor; \n\ varying mediump vec2 v_texCoord; \n\ @@ -15,7 +38,7 @@ varying vec2 v_texCoord; \n\ \n\ void main() \n\ { \n\ - gl_Position = u_MVPMatrix * a_position; \n\ + gl_Position = CC_MVPMatrix * a_position; \n\ v_fragmentColor = a_color; \n\ v_texCoord = a_texCoord; \n\ } \n\ diff --git a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_frag.h b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_frag.h index d7af10e..93a8f0e 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_frag.h +++ b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_frag.h @@ -1,13 +1,38 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ #endif \n\ \n\ varying vec2 v_texCoord; \n\ -uniform sampler2D u_texture; \n\ +uniform sampler2D CC_Texture0; \n\ \n\ void main() \n\ { \n\ - gl_FragColor = texture2D(u_texture, v_texCoord); \n\ + gl_FragColor = texture2D(CC_Texture0, v_texCoord); \n\ } \n\ "; diff --git a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_uColor_frag.h b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_uColor_frag.h index 019f2ef..a97d250 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_uColor_frag.h +++ b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_uColor_frag.h @@ -1,3 +1,28 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ @@ -7,10 +32,10 @@ uniform vec4 u_color; \n\ \n\ varying vec2 v_texCoord; \n\ \n\ -uniform sampler2D u_texture; \n\ +uniform sampler2D CC_Texture0; \n\ \n\ void main() \n\ { \n\ - gl_FragColor = texture2D(u_texture, v_texCoord) * u_color; \n\ + gl_FragColor = texture2D(CC_Texture0, v_texCoord) * u_color; \n\ } \n\ "; diff --git a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_uColor_vert.h b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_uColor_vert.h index ca36ff0..9d2bfd3 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_uColor_vert.h +++ b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_uColor_vert.h @@ -1,9 +1,32 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + " \n\ attribute vec4 a_position; \n\ attribute vec2 a_texCoord; \n\ \n\ -uniform mat4 u_MVPMatrix; \n\ - \n\ #ifdef GL_ES \n\ varying mediump vec2 v_texCoord; \n\ #else \n\ @@ -12,7 +35,7 @@ varying vec2 v_texCoord; \n\ \n\ void main() \n\ { \n\ - gl_Position = u_MVPMatrix * a_position; \n\ + gl_Position = CC_MVPMatrix * a_position; \n\ v_texCoord = a_texCoord; \n\ } \n\ "; diff --git a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_vert.h b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_vert.h index 98ceab5..1278ab0 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_vert.h +++ b/vendor/Pods/cocos2d/cocos2d/ccShader_PositionTexture_vert.h @@ -1,7 +1,31 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + " \n\ attribute vec4 a_position; \n\ attribute vec2 a_texCoord; \n\ -uniform mat4 u_MVPMatrix; \n\ \n\ #ifdef GL_ES \n\ varying mediump vec2 v_texCoord; \n\ @@ -11,7 +35,7 @@ varying vec2 v_texCoord; \n\ \n\ void main() \n\ { \n\ - gl_Position = u_MVPMatrix * a_position; \n\ + gl_Position = CC_MVPMatrix * a_position; \n\ v_texCoord = a_texCoord; \n\ } \n\ "; diff --git a/vendor/Pods/cocos2d/cocos2d/ccShader_Position_uColor_frag.h b/vendor/Pods/cocos2d/cocos2d/ccShader_Position_uColor_frag.h index 48e5ae6..d882c88 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccShader_Position_uColor_frag.h +++ b/vendor/Pods/cocos2d/cocos2d/ccShader_Position_uColor_frag.h @@ -1,3 +1,28 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ diff --git a/vendor/Pods/cocos2d/cocos2d/ccShader_Position_uColor_vert.h b/vendor/Pods/cocos2d/cocos2d/ccShader_Position_uColor_vert.h index 9f1ba38..c50e38b 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccShader_Position_uColor_vert.h +++ b/vendor/Pods/cocos2d/cocos2d/ccShader_Position_uColor_vert.h @@ -1,6 +1,30 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + " \n\ attribute vec4 a_position; \n\ -uniform mat4 u_MVPMatrix; \n\ uniform vec4 u_color; \n\ uniform float u_pointSize; \n\ \n\ @@ -12,7 +36,7 @@ varying vec4 v_fragmentColor; \n\ \n\ void main() \n\ { \n\ - gl_Position = u_MVPMatrix * a_position; \n\ + gl_Position = CC_MVPMatrix * a_position; \n\ gl_PointSize = u_pointSize; \n\ v_fragmentColor = u_color; \n\ } \n\ diff --git a/vendor/Pods/cocos2d/cocos2d/ccShaders.h b/vendor/Pods/cocos2d/cocos2d/ccShaders.h index 84b113f..076c3e0 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccShaders.h +++ b/vendor/Pods/cocos2d/cocos2d/ccShaders.h @@ -24,6 +24,10 @@ #import "Platforms/CCGL.h" +#ifdef __cplusplus__ +extern "C" { +#endif // __cplusplus__ + extern const GLchar * ccPosition_uColor_frag; extern const GLchar * ccPosition_uColor_vert; @@ -43,3 +47,10 @@ extern const GLchar * ccPositionTextureColorAlphaTest_frag; extern const GLchar * ccPositionTexture_uColor_frag; extern const GLchar * ccPositionTexture_uColor_vert; + +extern const GLchar * ccPositionColorLengthTexture_frag; +extern const GLchar * ccPositionColorLengthTexture_vert; + +#ifdef __cplusplus__ +} +#endif // __cplusplus__ diff --git a/vendor/Pods/cocos2d/cocos2d/ccShaders.m b/vendor/Pods/cocos2d/cocos2d/ccShaders.m index 36ca949..91dd677 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccShaders.m +++ b/vendor/Pods/cocos2d/cocos2d/ccShaders.m @@ -63,3 +63,11 @@ #import "ccShader_PositionTexture_uColor_frag.h" const GLchar * ccPositionTexture_uColor_vert = #import "ccShader_PositionTexture_uColor_vert.h" + +// +const GLchar * ccPositionColorLengthTexture_frag = +#import "ccShader_PositionColorLengthTexture_frag.h" + +const GLchar * ccPositionColorLengthTexture_vert = +#import "ccShader_PositionColorLengthTexture_vert.h" + diff --git a/vendor/Pods/cocos2d/cocos2d/ccTypes.h b/vendor/Pods/cocos2d/cocos2d/ccTypes.h index 730aa93..444ae21 100644 --- a/vendor/Pods/cocos2d/cocos2d/ccTypes.h +++ b/vendor/Pods/cocos2d/cocos2d/ccTypes.h @@ -41,6 +41,11 @@ /** RGB color composed of bytes 3 bytes @since v0.8 */ + +#ifdef __cplusplus +extern "C" { +#endif + typedef struct _ccColor3B { GLubyte r; @@ -55,7 +60,8 @@ ccc3(const GLubyte r, const GLubyte g, const GLubyte b) ccColor3B c = {r, g, b}; return c; } -//ccColor3B predefined colors + + //ccColor3B predefined colors //! White color (255,255,255) static const ccColor3B ccWHITE = {255,255,255}; //! Yellow color (255,255,0) @@ -93,17 +99,15 @@ ccc4(const GLubyte r, const GLubyte g, const GLubyte b, const GLubyte o) return c; } - /** RGBA color composed of 4 floats @since v0.8 */ -struct ccColor4F { +typedef struct _ccColor4F { GLfloat r; GLfloat g; GLfloat b; GLfloat a; -}; -typedef struct ccColor4F ccColor4F; +} ccColor4F; //! helper that creates a ccColor4f type static inline ccColor4F ccc4f(const GLfloat r, const GLfloat g, const GLfloat b, const GLfloat a) @@ -134,6 +138,13 @@ static inline BOOL ccc4FEqual(ccColor4F a, ccColor4F b) { return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a; } + +static inline ccColor4B ccc4BFromccc4F(ccColor4F c) +{ + return (ccColor4B){c.r*255.f, c.g*255.f, c.b*255.f, c.a*255.f}; +} + + /** A vertex composed of 2 GLfloats: x, y @since v0.8 @@ -264,7 +275,19 @@ typedef struct _ccV3F_C4B_T2F ccTex2F texCoords; // 8 byts } ccV3F_C4B_T2F; -//! 4 ccVertex2FTex2FColor4B Quad + +//! A Triangle of ccV2F_C4B_T2F +typedef struct _ccV2F_C4B_T2F_Triangle +{ + //! Point A + ccV2F_C4B_T2F a; + //! Point B + ccV2F_C4B_T2F b; + //! Point B + ccV2F_C4B_T2F c; +} ccV2F_C4B_T2F_Triangle; + +//! A Quad of ccV2F_C4B_T2F typedef struct _ccV2F_C4B_T2F_Quad { //! bottom left @@ -312,6 +335,8 @@ typedef struct _ccBlendFunc GLenum dst; } ccBlendFunc; +static const ccBlendFunc kCCBlendFuncDisable = {GL_ONE, GL_ZERO}; + //! ccResolutionType typedef enum { @@ -331,13 +356,13 @@ typedef enum //! Mac resolution type kCCResolutionMac, - //! Mac RetinaDisplay resolution type (???) + //! Mac RetinaDisplay resolution type kCCResolutionMacRetinaDisplay, #endif // platform } ccResolutionType; -// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m +// XXX: If any of these enums are edited and/or reordered, update CCTexture2D.m //! Vertical text alignment type typedef enum { @@ -346,7 +371,7 @@ typedef enum kCCVerticalTextAlignmentBottom, } CCVerticalTextAlignment; -// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m +// XXX: If any of these enums are edited and/or reordered, update CCTexture2D.m //! Horizontal text alignment type typedef enum { @@ -355,7 +380,7 @@ typedef enum kCCTextAlignmentRight, } CCTextAlignment; -// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m +// XXX: If any of these enums are edited and/or reordered, update CCTexture2D.m //! Line break modes typedef enum { kCCLineBreakModeWordWrap, @@ -372,3 +397,8 @@ typedef float ccTime; //typedef double ccTime; typedef float ccMat4[16]; + +#ifdef __cplusplus +} +#endif + diff --git a/vendor/Pods/cocos2d/cocos2d/cocos2d.h b/vendor/Pods/cocos2d/cocos2d/cocos2d.h index 87fda39..f9dc29d 100644 --- a/vendor/Pods/cocos2d/cocos2d/cocos2d.h +++ b/vendor/Pods/cocos2d/cocos2d/cocos2d.h @@ -39,8 +39,8 @@ */ // 0x00 HI ME LO -// 00 02 00 00 -#define COCOS2D_VERSION 0x00020000 +// 00 02 01 00 +#define COCOS2D_VERSION 0x00020100 // @@ -112,6 +112,7 @@ #import "CCRenderTexture.h" #import "CCMotionStreak.h" #import "CCConfiguration.h" +#import "CCDrawNode.h" // Shaders #import "CCGLProgram.h" @@ -159,6 +160,9 @@ #import "Support/ccUtils.h" #import "Support/TransformUtils.h" #import "Support/CCProfiling.h" +#import "Support/NSThread+performBlock.h" +#import "Support/uthash.h" +#import "Support/utlist.h" // // external @@ -168,9 +172,18 @@ +#ifdef __cplusplus +extern "C" { +#endif + // free functions NSString * cocos2dVersion(void); +#ifdef __cplusplus +} +#endif + + #ifdef __CC_PLATFORM_IOS #ifndef __IPHONE_4_0 #error "If you are targeting iPad, you should set BASE SDK = 4.0 (or 4.1, or 4.2), and set the 'iOS deploy target' = 3.2" diff --git a/vendor/Pods/cocos2d/cocos2d/cocos2d.m b/vendor/Pods/cocos2d/cocos2d/cocos2d.m index db52e21..052b484 100644 --- a/vendor/Pods/cocos2d/cocos2d/cocos2d.m +++ b/vendor/Pods/cocos2d/cocos2d/cocos2d.m @@ -26,7 +26,7 @@ #import #import "cocos2d.h" -static NSString *version = @"cocos2d v2.0.0"; +static NSString *version = @"cocos2d v2.1-beta-pre"; NSString *cocos2dVersion() {