The following image shows the problem.
When I launch my app from background after a while, I found some CCsprites on the CCScene turns to black.
I have no idea about the reason(I guess it related to memory?).
Any suggestion?
PS. All the code is running on the main thread, so there should be no thread issues
Related
On screen 0, I have the mainWindow with two QOpenGLWidgets running video. On screen 1, I have another QOpenGLWidget in fullscreen mode running video. The screen 0 is a preview of what the user is seeing on the second display, which is a pair of glasses. Everything was working fine, until I added the fullscreen widget. Now only the fullscreen widget updates and the other two only update if I cause the window to repaint, e.g. moving the window.
I am a noob when it comes to opengl, but the two widgets, in the mainWindow are running together fine. So I don't believe it is the code. Is this a limitation of opengl? Qt? me?
I am using Qt5.4.
I missed an error in the console due to a lot of noise.
Requires a valid current OpenGL context.
Texture has not been destroyed
A quick search and I got my answer. I wasn't calling makeCurrent() when I was updating the texture with the next frame.
Problem: I have a CCSprite animation that uses 7 frames. It works fine when I run the action with a delay of .04f, however, I need to run this animation at .02f which causes it to completely stop about 2~3 frames into the sprite animation. Bumping it up to .03f gets about 4~5 frames in before the sprite freezes.
I can't post the code because there's way too much. Really I'm looking for a general idea of where to start looking. The CCSprite I'm calling the runaction on is being retained, so that doesn't seem to be the issue. Thoughts?
I have a cocos2d game that has a loading scene where we load a bunch of assets. The game starts with the splash screen, and then launches the loading scene. The loading scene starts by loading the background, so the user sees the loading scene background while the assets are being loaded.
I load the loading scene background by calling CCSprite::spriteWithFile: and passing the filepath: loadingbackground.pvr.ccz
It seems to work differently on different devices:
On iphone (3gs) simulator, I see the loading scene as expected.
On iphone retina simulator, I don't see the loading scene (there aren't many assets yet, so may be happening quickly) and it goes directly to the main menu scene.
On the ipad 3 device, the splash screen comes up, and then there is a half second of black screen, and then the main menu scene shows up.
I want to see what I can do to avoid that black screen showing up on iPad 3. I suspect this is because of the time taken to load the loading background.
I have tried the following optimizations (mostly based on #Steffen's blog post on memory optimization):
Moved the loading background (originally 2.3 MB RGB8 png file) into a pvr.ccz spritesheet by itself, which reduced its size to 1.8 MB.
Removed the image from the texture soon after use.
I still see a black screen on iPad 3. Any suggestions?
Update: Found the issue - I had some code where I was overriding OnEnter and calling [[CCDirector sharedDirector]replaceScene] in it, and also calling the same from the background thread. Removed the OnEnter overload and it worked without flicker.
Thanks
Ignore whatever happens in Simulator. That's not relevant, focus on the device.
When the loading scene initializes and you add the loading scene's background, make sure you schedule update and load your assets in the update method. Otherwise if you load the assets in init, the background won't be drawn because you're loading all the assets before cocos2d gets to redraw the screen.
If this still fails, simply send the visit message to the background sprite followed by [[CCDirector sharedDirector] drawScene]. This forces a redraw of the scene.
Is this cocos2d-iphone or cocos2d-x ? make sure the tags are correct :)
I think you're referring to the startup flicker, there are a few ways to avoid that.
first thing you need to make sure you're handling the rootViewController correctly for iOS 6 and iOS 5 and below, there are a little changes for each.
You can find a little reference here:
http://www.cocos2d-iphone.org/forum/topic/34471
Second thing you need to know that simulator's behaviour is not stable, you should always rely on real devices for testing, but it's very likely you'll still have the flicker issues.
Sorry I didn't provide example code, but you haven't supported enough information to know what's the real issue here.
i have an issue on resuming, when my app resumes then my labels appears to have a black background if there was any label just at the time of pausing the game. Can anyone please help how to resolve this issue ?
Thanks!!
Some times textures disappear from sprites. I have a sprite that appears with white color and it should have a texture on it and a label that should have a text in it an it appears with black color. The labels are subclasses of sprite so this problem is related to Sprites. Could some one tell me what is the problem ? Did some one meet this bug to in Cococs2D on Android ? Thank's !
I had such a problem when I was doing navigation from "outside" of cocos2d i.e. i relied on Android's native back button's callback to change scenes. Apparently this callback doesn't work on the same thread as cocos and causes this problem (maybe something with WeakReferences in the TextureCache). Hope it helps :)
Are you using pvr? When I tried using pvr I was getting what sounds like the same issues. I switched to png and it fixed the problem for me.