filterSekai

Hi, I tried to use cocos2d to load spine assets. Basically, I want to embed CCScene in top of UIView. I found this piece of code
- (void)setupCocos2D {
CCGLView *glView = [CCGLView viewWithFrame:[[self view] frame]
pixelFormat:kEAGLColorFormatRGB565 // kEAGLColorFormatRGBA8
depthFormat:0 // GL_DEPTH_COMPONENT16_OES
];
glView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view insertSubview:glView atIndex:0];

[[CCDirector sharedDirector] setView:glView];
CCScene *scene = [GoblinsExample scene];
[[CCDirector sharedDirector] runWithScene:scene];
}
After I run, I get this success log in XCode
cocos2d: Cocos2D-ObjC version 3.5.0
cocos2d: compiled with Profiling Support: NO
cocos2d: OS version: 12.1 (0x0c010000)
cocos2d: 64 bit runtime
cocos2d: Multi-threaded rendering: 0
cocos2d: OpenGL Rendering enabled.cocos2d: GL_VENDOR: Apple Inc.
cocos2d: GL_RENDERER: Apple Software Renderer
cocos2d: GL_VERSION: OpenGL ES 2.0 APPLE-17.0.37
cocos2d: GLSL_VERSION: OpenGL ES GLSL ES 1.00
cocos2d: GL_MAX_TEXTURE_SIZE: 4096
cocos2d: GL_MAX_TEXTURE_UNITS: 8
cocos2d: GL_MAX_SAMPLES: 4
cocos2d: GL supports PVRTC: YES
cocos2d: GL supports BGRA8888 textures: YES
cocos2d: GL supports NPOT textures: YES
cocos2d: GL supports discard_framebuffer: YES
cocos2d: GL supports shareable VAO: NO
cocos2d: CCGraphicsBufferClass: CCGraphicsBufferGLUnsynchronized
cocos2d: CCGraphicsBufferBindingsClass: CCGraphicsBufferBindingsGL
cocos2d: CCRenderCommandDrawClass: CCRenderCommandDrawGL
2019-07-29 16:47:21.203056+0700 Ruangguru[72492:4759566] cocos2d: surface size: 750x1624
This log exactly looks like the example project. It also showing CCDirectorDisplayLink layer in my view.

So my question is, did I miss something here? Any help would be appreciated. Thank you.
filterSekai
  • Posts: 17

badlogic

You haven't told us what the problem is :)
User avatar
badlogic

Mario
  • Posts: 1936

filterSekai

badlogic wrote:You haven't told us what the problem is :)
Forget to mention it :grinteeth:

My problem actually the goblins scene doesn't show up at UIView, only blank white page.

---

filterSekai wrote:
badlogic wrote:You haven't told us what the problem is :)
Forget to mention it :grinteeth:

My problem actually the goblins scene doesn't show up at UIView, only blank white page.
---

Solved

I solved the problem with manually start the animation:
[[CCDirector sharedDirector] startAnimation];
I have successfully add the scene above UIView. But i have another problem, the goblins cannot resize into my UIView. This is what i did to resize, I set glView.autoresizingMask but the result is still the same
CCGLView *glView = [CCGLView viewWithFrame:[self.eggView bounds]
pixelFormat:kEAGLColorFormatRGB565 // kEAGLColorFormatRGBA8
depthFormat:0 // GL_DEPTH_COMPONENT16_OES
];
glView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.eggView insertSubview:glView atIndex:0];
Any ideas?


---


Solved by set the scale. Thank you!
filterSekai
  • Posts: 17


Return to Runtimes