Presentation is loading. Please wait.

Presentation is loading. Please wait.

CCSprite *sprite = [CCSprite [sprite runAction: [CCRepeatForever actionWithAction: [CCSequence actions: [CCEaseIn.

Similar presentations


Presentation on theme: "CCSprite *sprite = [CCSprite [sprite runAction: [CCRepeatForever actionWithAction: [CCSequence actions: [CCEaseIn."— Presentation transcript:

1

2

3

4

5

6

7

8 CCSprite *sprite = [CCSprite spriteWithFile:@”ball.png”]; [sprite runAction: [CCRepeatForever actionWithAction: [CCSequence actions: [CCEaseIn actionWithAction: [CCRotateBy actionWithDuration:0.5 angle:30.0] rate:2], [CCEaseOut actionWithAction: [CCRotateBy actionWithDuration:0.5 angle:-30.0] rate:2], nil ] ]; CCSprite *sprite = [CCSprite spriteWithFile:@”ball.png”]; [sprite runAction: [CCRepeatForever actionWithAction: [CCSequence actions: [CCEaseIn actionWithAction: [CCRotateBy actionWithDuration:0.5 angle:30.0] rate:2], [CCEaseOut actionWithAction: [CCRotateBy actionWithDuration:0.5 angle:-30.0] rate:2], nil ] ] ];

9

10

11 CCSprite *sprite = [CCSprite spriteWithFile:@”ball.png”];

12 glGenVertexArrays(1, &_vao); glBindVertexArray(_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); glBindVertexArray(0);... glActiveTexture( GL_TEXTURE0 + textureUnit ); glBindTexture(GL_TEXTURE_2D, textureId ); glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);... glGenVertexArrays(1, &_vao); glBindVertexArray(_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); glBindVertexArray(0);... glActiveTexture( GL_TEXTURE0 + textureUnit ); glBindTexture(GL_TEXTURE_2D, textureId ); glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);... ccColor4B color = (ccColor4B){255, 255, 255, 255}; vertices[0] = {{ 0.0, 100.0}, color, {0.0, 1.0}}; vertices[1] = {{ 0.0, 0.0}, color, {0.0, 0.0}}; vertices[2] = {{100.0, 100.0}, color, {1.0, 1.0}}; vertices[3] = {{ 0.0, 0.0}, color, {0.0, 0.0}}; vertices[4] = {{100.0, 100.0}, color, {1.0, 1.0}}; vertices[5] = {{100.0, 0.0}, color, {1.0, 0.0}}; ccColor4B color = (ccColor4B){255, 255, 255, 255}; vertices[0] = {{ 0.0, 100.0}, color, {0.0, 1.0}}; vertices[1] = {{ 0.0, 0.0}, color, {0.0, 0.0}}; vertices[2] = {{100.0, 100.0}, color, {1.0, 1.0}}; vertices[3] = {{ 0.0, 0.0}, color, {0.0, 0.0}}; vertices[4] = {{100.0, 100.0}, color, {1.0, 1.0}}; vertices[5] = {{100.0, 0.0}, color, {1.0, 0.0}};

13

14 glRotatef(m_currentAngle, 0, 0, 1); float radians = m_currentAngle * Pi / 180.0f; float s = sinf(radians); float c = cosf(radians); float zRotation[16] = { c, s, 0, 0, -s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; GLint modelviewUniform = glGetUniformLocation(m_simpleProgram, "CC_MVPMatrix"); glUniformMatrix4fv(modelviewUniform, 1, 0, &zRotation[0]); float radians = m_currentAngle * Pi / 180.0f; float s = sinf(radians); float c = cosf(radians); float zRotation[16] = { c, s, 0, 0, -s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; GLint modelviewUniform = glGetUniformLocation(m_simpleProgram, "CC_MVPMatrix"); glUniformMatrix4fv(modelviewUniform, 1, 0, &zRotation[0]);

15 uniform mat4 CC_MVPMatrix; attribute vec4 a_position; attribute vec2 a_texCoord; attribute vec4 a_color; varying lowp vec4 v_fragmentColor; varying mediump vec2 v_texCoord; void main() { gl_Position = CC_MVPMatrix * a_position; v_fragmentColor = a_color; v_texCoord = a_texCoord; } uniform mat4 CC_MVPMatrix; attribute vec4 a_position; attribute vec2 a_texCoord; attribute vec4 a_color; varying lowp vec4 v_fragmentColor; varying mediump vec2 v_texCoord; void main() { gl_Position = CC_MVPMatrix * a_position; v_fragmentColor = a_color; v_texCoord = a_texCoord; } varying vec4 v_fragmentColor; varying vec2 v_texCoord; uniform sampler2D CC_Texture0; void main() { lowp vec4 color = v_fragmentColor * texture2D(CC_Texture0, v_texCoord); gl_FragColor = color; } varying vec4 v_fragmentColor; varying vec2 v_texCoord; uniform sampler2D CC_Texture0; void main() { lowp vec4 color = v_fragmentColor * texture2D(CC_Texture0, v_texCoord); gl_FragColor = color; }

16

17

18


Download ppt "CCSprite *sprite = [CCSprite [sprite runAction: [CCRepeatForever actionWithAction: [CCSequence actions: [CCEaseIn."

Similar presentations


Ads by Google