@@ -32,6 +32,7 @@ @interface CCEffectNode()
32
32
{
33
33
CCEffect *_effect;
34
34
CCEffectRenderer *_effectRenderer;
35
+ CGSize _allocatedSize;
35
36
}
36
37
37
38
@end
@@ -48,6 +49,7 @@ -(id)initWithWidth:(int)width height:(int)height
48
49
{
49
50
if ((self = [super initWithWidth: width height: height pixelFormat: CCTexturePixelFormat_Default])) {
50
51
_effectRenderer = [[CCEffectRenderer alloc ] init ];
52
+ _allocatedSize = CGSizeMake (0 .0f , 0 .0f );
51
53
}
52
54
return self;
53
55
}
@@ -72,14 +74,20 @@ -(void)setEffect:(CCEffect *)effect
72
74
73
75
-(void )create
74
76
{
75
- CGSize pointSize = self.contentSizeInPoints ;
76
- CGSize pixelSize = CGSizeMake (pointSize .width * _contentScale, pointSize .height * _contentScale);
77
+ _allocatedSize = self.contentSizeInPoints ;
78
+ CGSize pixelSize = CGSizeMake (_allocatedSize .width * _contentScale, _allocatedSize .height * _contentScale);
77
79
[self createTextureAndFboWithPixelSize: pixelSize];
78
80
79
- CGRect rect = CGRectMake (0 , 0 , pointSize .width , pointSize .height );
81
+ CGRect rect = CGRectMake (0 , 0 , _allocatedSize .width , _allocatedSize .height );
80
82
[_sprite setTextureRect: rect];
81
83
82
- _projection = GLKMatrix4MakeOrtho (0 .0f , pointSize.width , 0 .0f , pointSize.height , -1024 .0f , 1024 .0f );
84
+ _projection = GLKMatrix4MakeOrtho (0 .0f , _allocatedSize.width , 0 .0f , _allocatedSize.height , -1024 .0f , 1024 .0f );
85
+ }
86
+
87
+ -(void )destroy
88
+ {
89
+ [super destroy ];
90
+ _allocatedSize = CGSizeMake (0 .0f , 0 .0f );
83
91
}
84
92
85
93
-(void )begin
@@ -123,9 +131,11 @@ -(void)visit:(CCRenderer *)renderer parentTransform:(const GLKMatrix4 *)parentTr
123
131
// Don't call visit on its children
124
132
if (!_visible) return ;
125
133
126
- if (_contentSizeChanged)
134
+ CGSize pointSize = self.contentSizeInPoints ;
135
+ if (!CGSizeEqualToSize (pointSize, _allocatedSize))
127
136
{
128
137
[self destroy ];
138
+ [self contentSizeChanged ];
129
139
_contentSizeChanged = NO ;
130
140
}
131
141
@@ -224,10 +234,4 @@ - (void)updateShaderUniformsFromEffect
224
234
[_shaderUniforms addEntriesFromDictionary: _effect.shaderUniforms];
225
235
}
226
236
227
- - (void )setContentSizeType : (CCSizeType)contentSizeType
228
- {
229
- [super setContentSizeType: contentSizeType];
230
- _contentSizeChanged = YES ;
231
- }
232
-
233
237
@end
0 commit comments