cocos2d-iPhone安装

1. 去 http://cocos2d-objc.org/downloads下载
file:///Users/wizjin/Library/Containers/com.tencent.qq/Data/Library/Application%20Support/QQ/Users/2528282451/QQ/Temp.db/EE3E7191-75AC-4E92-B610-FF0E35DF12D4.png
2.在cocos2d-iphone-classic-2.2中找到install-templates.sh  在电脑终端打开      cocos2d-iphone-classic-2.2所在文件夹  

cd ../cocos2d-iphone-classic-2.2 进入该文件夹 使用./install-templates.sh运行该脚本    

3.完成后打开xcode 即可看到

file:///Users/wizjin/Library/Containers/com.tencent.qq/Data/Library/Application%20Support/QQ/Users/2528282451/QQ/Temp.db/8FBFB298-8E57-4D3E-92D4-A9B52C24C3AF.png 选择第一个会生成一个建一个工程直接运行
4.若工程报错,

到报错地点将该方法代码替换为

#define EXTENSION_STRING "#extension GL_OES_standard_derivatives : enable"

static NSString * g_extensionStr = @EXTENSION_STRING;



- (BOOL)compileShader:(GLuint *)shader type:(GLenum)type byteArray:(constGLchar *)source

{

    GLint status;


//    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,

// };

    if (!source)

        returnNO;

    

    // BEGIN workaround for Xcode 7 bug

    BOOL hasExtension =NO;

    NSString *sourceStr = [NSStringstringWithUTF8String:source];

    if([sourceStrrangeOfString:g_extensionStr].location !=NSNotFound) {

        hasExtension = YES;

        NSArray *strs = [sourceStrcomponentsSeparatedByString:g_extensionStr];

        assert(strs.count ==2);

        sourceStr = [strs componentsJoinedByString:@"\n"];

        source = (GLchar *)[sourceStrUTF8String];

    }

    

    constGLchar *sources[] = {

        (hasExtension ? EXTENSION_STRING"\n" : ""),

#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,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: %@", [selfvertexShaderLog] );

else

CCLOG(@"cocos2d: %@", [selffragmentShaderLog] );

abort();

}

    return ( status ==GL_TRUE );

}


即可看到一个hello world 



你可能感兴趣的:(iOS,cocos2d-iPhone,安装)