I need to use CCTransitionPageTurn in my app between scenes.
When i run this transition, my running scene looks nice - it turns like page.
but at the background i see black screen(during page turn animation), that is replaced later by new scene.
And i want to see new scene in the background(during animation), when i start this transition.
Can anybody help me?
Oh, i found out the answer.
All works as it should, after i commented out this line
//director.projection = kCCDirectorProjection2D;
also i turned on depth buffer and changed depthformat.
Related
I've been trying to successfully create a slide transition between 2 scenes for the past 2 hours and all I can find are just some answers in Objective-C and I have no idea how to translate them.
I'm using XCode 5 with Cocos2D-X 2.2.3 to develop for iOS.
CCTransitionSlideInT *trans = CCTransitionSlideInT::create(1.0, Scene2::scene());
CCDirector::sharedDirector()->replaceScene(trans);
Doing that makes my current scene slide down and gets replaced by black (background) THEN after the transition is done, the second scene appears without any transition effects; it just appears.
How can I slide the first scene with the second one attached to it?
I've seen that it's done in TestCPP. I tried tracing it but it got too complicated for me. All I really need is some clarification!
Thanks in advance! And I hope I provided all the necessary info.
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'm wanting to create a WoW cooldown effect where a player does some action and is not able to do the action again until the sprite is fully shown again. I have a grayed out version of the same sprite and am wanting to slowly reveal the sprite until it is fully available again. So, there will be a slow blend vertically of the gray and colored sprite.
Is there a way to do this with built in functionality with Cocos2d and CCSprite?
I'm using v2 of Cocos2d so I could write a shader which I think would be pretty easy, but before I went this route I wanted to see if there is an easier way.
Take a look to the CCProgressTimer class. If I understand right, it will make what you want
You can use CCFadeIn to animate the colored sprite over the grayed sprite :
[coloredSprite runAction:[CCFadeIn actionWithDuration:1.0f];
I am struggling with my first semi basic game for iPhone. The game operates well but I want a button to display saying restart and then when clicked it restarts the scene. This button should only appear when my sprite (called sprite) falls below the bottom of the iphone screen. I am using both cocos 2d and box 2d if that makes a difference.
Thank you for the help in advanced, it is greatly appreciated!
Quick answer for having the button appear once the sprite falls below a certain point: When you create the button, set its state to not visible. resetButton.isVisible = NO; Then write an if statement about your sprite's position and enable the button once that happens.
if (sprite.position.y >= 0)
{
resetButton.isVisible = YES;
}
This should get you started on that aspect. I'm not at my Mac right now, but if memory serves, a non-visible button is not enabled, so clicking on its location won't matter. If that's incorrect, just add in resetButton.isEnabled = NO; and YES appropriately.
As for resetting the scene, this can get a little tricky depending on what exactly you want to accomplish. You need to essentially replace the scene with itself, but this can cause undesirable flashes. A quick google search found a bunch of forum posts on this. If you can elaborate on what you've already tried and where you're getting caught up, I can try and get more specific.
I'm trying to implement some drag and drop functionality for a material system being developed at my work. Part of this system includes a 'Material Library' which acts as a repository, divided into groups, of saved materials on the user's hard drive.
As part of some UI polish, I was hoping to implement a 'highlight' type feature. When dragging and dropping, windows that you can legally drop a material onto will very subtly change color to improve feedback to the user that this is a valid action.
I am changing the bar with 'Basic Materials' (Just a CWnd with a CStatic) from having a medium gray background when unhighlighed to a blue background when hovered over. It all works well, the OnDragEnter and OnDragExit messages seem robust and set a flag indicating the highlight status. Then in OnCtrlColor I do this:
if (!m_bHighlighted) {
pDC->FillSolidRect(0, 0, m_SizeX, kGroupHeaderHeight, kBackgroundColour);
}
else {
pDC->FillSolidRect(0, 0, m_SizeX, kGroupHeaderHeight, kHighlightedBackgroundColour);
}
However, as you can see in the screenshot, the painting 'glitches' below the dragged object, leaving the original gray in place. It looks really ugly and basically spoils the whole effect.
Is there any way I can get around this?
Remote debugging is a godsend for debugging visual issues. It's a pain to set up, but having a VM ready for remote debugging will pay off for sure.
What I like to do is set a ton of breakpoints in my paint handling, as well as in the framework paint code itself. This allows you to effectively "freeze frame" the painting without borking it up by flipping into devenv. This way you can get the true picture of who's painting in what order, and where you've got the chance to break in a fill that rect the way you need to.
It almost looks like the CStatic doesn't know that it needs to repaint itself, so the background color of the draggable object is left behind. Maybe try to invalidate the CStatic, and see if that helps at all?
Thanks for the answers guys, ajryan, you seem to always come up with help for my questions so extra thanks.
Thankfully this time the answer was fairly straightforward....
ImageList_DragShowNolock(FALSE);
m_pDragDropTargetWnd->SendMessage(WM_USER_DRAG_DROP_OBJECT_DRAG_ENTER, (WPARAM)pDragDropObject, (LPARAM)(&dragDropPoint));
ImageList_DragShowNolock(TRUE);
This turns off the drawing of the dragged image, then sends a message to the window being entered to repaint in a highlighted state, then finally redraws the drag image over the top. Seems to have done the trick.