[cocos2D] 프로젝트에, OpenGL ES와 iphone framework이 동시에 있을때 좌표
OpenGL ES의 함수인  glViewport등 gl붙은 함수들이 모여있는 renderScene함수속에서 호출되는 함수상의 x y좌표 0.0은 수학적 좌표로 좌측하단에 있다. 심지어 이 함수 내부에서 콜되는 sprite의 함수도 만찮가지

- (void)renderScene {
    
// If OpenGL has not yet been initialised then go and initialise it
if(!glInitialised) {
[selfinitOpenGL];
}
    
// Set the current EAGLContext and bind to the framebuffer.This will direct all OGL commands to the
// framebuffer and the associated renderbuffer attachment which is where our scene will be rendered
[EAGLContextsetCurrentContext:context];
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
    
// Define the viewport.Changing the settings for the viewport can allow you to scale the viewport
// as well as the dimensions etc and so I'm setting it for each frame in case we want to change it
glViewport(0, 0, screenBounds.size.width , screenBounds.size.height);

// Clear the screen.If we are going to draw a background image then this clear is not necessary
// as drawing the background image will destroy the previous image
glClear(GL_COLOR_BUFFER_BIT);

// Setup how the images are to be blended when rendered.This could be changed at different points during your
// render process if you wanted to apply different effects
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);


[font1drawStringAt:CGPointMake(messageX, 100) text:message];
//[anim renderAtPoint:CGPointMake(70, 100)];
//[animThunder renderAtPoint:CGPointMake(180, 150)];
[animrenderAtPoint:CGPointMake(70, 5)];
[animThunderrenderAtPoint:CGPointMake(2, 180)];



// Bind to the renderbuffer and then present this image to the current context
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
    [contextpresentRenderbuffer:GL_RENDERBUFFER_OES];
}

아이폰 API함수의 좌표는 우측하단이다
아래의 함수상에서 호출되는 함수들의 좌표 x,y 는 우측상단이 0,0이다.


-(void)BallMoving{




float x = fireBall.center.x;
float y = fireBall.center.y;

fireBall.center = CGPointMake(fireBall.center.x + pos.x, fireBall.center.y + pos.y);
//
/
//방향전환만한다.
if (fireBall.center.x > 320 || fireBall.center.x < 0){

pos.x = -pos.x;
//찌그러뜨림


....
}

Posted by 오늘마감