這讓我很生氣。我不得不GLfloat在一個CCNODE類的實現接下來的分配,在側視圖模擬瓦爾特(它來自一類,我在cocos2dForum找到) 更新:從不兼容的類型調整爲GLfloat void
-(id)initWithBounds:(CGRect)bounds count:(int)count damping:(float)damping diffusion:(float)diffusion;
{
if((self = [super init])){
_bounds = bounds;
_count = count;
_damping = damping;
_diffusion = diffusion;
_color = ccc4f(1.0f, 1.0f, 1.0f, 1.0f);
_h1 = calloc(_count, sizeof(float));//Here
_h2 = calloc(_count, sizeof(float));// And here, is where I get the error.
WaterTexture = [[CCTextureCache sharedTextureCache] addImage:@"watter.png"];
//shader_ = [[CCShaderCache sharedShaderCache] programForKey:kCCShader_Position_uColor];
shader_ = [[CCShaderCache sharedShaderCache] programForKey:kCCShader_PositionTexture];
_textureLocation = glGetUniformLocation(shader_->_program, "u_texture");
texturesize= 256*CC_CONTENT_SCALE_FACTOR();
offset=0;
}
return self;
}
- (void)dealloc
{
free(_h1);
free(_h2);
[super dealloc];
}
這個類是在Cocos3d實施項目。在添加Box2d庫之前,所有工作都正常,水被模擬,但是在添加Box2D庫之後,XCode開始抱怨說「從不兼容的類型void分配給GLfloat」 爲什麼會發生這種情況?這是非常罕見的... 關心。 卡洛斯。
box2d - >您是否將實現文件更改爲.mm擴展名? – LearnCocos2D
是的,我確實很奇怪。 – Caferlop
您需要發佈更多代碼(特別是在您對GLFloat類型變量進行賦值的情況下)並標記發生錯誤的行。 – LearnCocos2D