来自spritesheet和着色器的Cocos 2d Iphone v3 Sprite

时间:2014-04-22 07:53:58

标签: cocos2d-iphone shader sprite

搜索stackoverflow并且Google没有返回任何结果。

 [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"sun.plist"];
 CCSprite* sprite = [CCSprite spriteWithImageNamed:@"8.jpg" ];
 sprite.position = ccp(self.contentSize.width/2 + 300, self.contentSize.height/2);
 [self addChild: sprite];

显示屏显示plist

中选定的精灵

但如果我应用着色器程序,则精灵重叠

解决方案是什么? 没有着色器: enter image description here

重叠:

enter image description here

THX

--- UPDT 05.05.2014

@interface gSprite : CCSprite
...
- (void) draw;
@end

- (void) draw{
....
            _shaderProgram = [[CCShaderCache sharedShaderCache] programForKey:@"LightingBlurShader"];
            [_shaderProgram  use];
            [_shaderProgram setUniformsForBuiltins];

            glUniform1i([[Engine sharedEngine] lightCount], activeLighCount);
            glUniform2fv([[Engine sharedEngine] lightPositionUniformLocation], activeLighCount, arrayLigthPos);
            glUniform1fv([[Engine sharedEngine] lightFalloffUniformLocation],activeLighCount, arrayLightFalloff);
            glUniform1fv([[Engine sharedEngine] lightIntensityUniformLocation], activeLighCount, arrayLightIntensity);
....

[super draw];

} //draw

0 个答案:

没有答案