I have a Scene that contains a GamePlay layer and an HUDLayer which contains my pause menu. I was wondering if there was anyway to pause just one layer in a scene so that I can pause the GamePlay layer but still access and click inside the pause menu in my HUDLayer. I tried using
[[CCDirector sharedDirector] pause];
but that pauses everything and doesn't accept touches in my pause menu. If there is no way to pause a single layer, what is the best way to incorporate a pause menu into a game? Thanks.
P.S. I am using the most recent version of cocos2d which is cocos2d 2.0.
This tutorial should help.
But basically what you wanna do is unschedule your scene then on resume reschedule it.
Here is what I did in my HUD layer.
-(void)pause:(id)sender
{
if(paused)
{
[gamescene scheduleUpdate];
}
else {
[gamescene unscheduleUpdate];
}
paused =!paused;
}
You shouldn't need to "pause" the desired layer unless I'm missing something. Why can't you just disable touches on everything except the pause layer while the pause layer is showing? It seems that is the end result that you would like anyways?
Related
I have pulled the animation to the Motion tab both by dragging and trough the select motion search function but neither makes the animation stick to my idle state. Can someone give me a pointer to what im doing wrong?
One reason could be that the animations are marked as legacy.
Select one or many animation, in the inspector next to the lock, right click, then Debug. Untick the Legacy. No need to save or else.
The animation which you're trying to set is for another model!
You should use an animation that is for the model.
Or if you insist on using that animation select animation from assets and do a "Control + D" to duplicate it and use new one.
Use the Animator, not the animation controller. I made this mistake when I was following a tutorial. This is only relevant if you are animating .anim files within unity itself. Animation controller is the way to go if you import animations for your specific model.
Is there a way to stop touch interaction when animation sequence is running. Animation sequence is load from ccbi file.
CCBAnimationManager* animationManager = self.userObject;
[animationManager runAnimationsForSequenceNamed:#"Blink"];
This depends on what interaction do you want to stop.
If it is a CCLayer, then set layer.touchEnabled = NO; and it will stop receiving touches. If it is your custom UI component, then you have to manually remove the touch delegate from it and add it when the animation ends.
Don't forget that you can set animationManager.delegate = self to get a callback when the animation finishes, so you can enable the touches again.
I'm trying to include splash screen into my XNA project while content is loading. I tried few tutorials but none has helped me. I was trying load content in update method, forcing draw method etc. Since I'm doing my project on Windows PC only I'm looking for a solution to display splash screen (propably animated) in the center of desktop. When content is loaded splash screen should disappear and the game screen should pop up.
I'm looking for some advices and tips how do it since I can't find any help on the Internet.
Personally I was thinking about using Forms but I don't know it well to use it properly.
Thanks in advance.
Since you are loading content, you are probably making a method call that spans over many frames. If you make that call on the GUI thread, you will freeze the game, which isn't what you want.
Instead, call the method inside a Task, and set your game's state as 'loading', and when the task is done, set a state that indicates the task is done.
Then, in your drawing method, you can do something like this:
if (state == State.Loading)
// draw loading screen
else if (State == .....
Extending on what Kendall Fray said, You could use game states like so:
public static GameState currentGameState = GameState.Loading;
public enum GameState
{
Loading, Whatever
}
and on Update or draw:
switch (currentGameState)
{
case (GameState.Loading):
//draw load screen
break;
case (GameState.Whatever):
break;
}
I am using Xcode to create a Cocoa app for Mac OSX written in Objective-C. I was wondering if I could use an NSTimer to make a label Smoothly disappear after a certain time after I have clicked a button.
Or I thought I could use this code:
- (IBAction)clickToLoadAppButtonClicked:(id)sender; {
[self performSelector:#selector(delayedLoad) withObject:nil afterDelay:3.0]
}
All I would need to do would be to add a void function called delayedLoad. I just need to know the code to make the label smoothly disappear so I can put it in the void...
Please help and thanks guys :D
You can do it using core animation:
[[myLabel animator] setAlphaValue:0.0];
This animates to transparent over a default period of 0.25 seconds.
See here for some further explanation or here for the full docs.
I have a custom view that is a subview of the main window. I have a timer that fires a [self setNeedsDisplay:TRUE] that will update drawing on the view. But from what I can see, if I leave the application on the background and switch to another, it does not reflect the new drawing functions until I click again on the application.
What could I be missing?
Thank you,
Jose.
setNeedsDisplay will not fire if it thinks the user cant see what its drawing for obvious reason. This includes, offscreen and obscured views even when the app is running.
In an app where you might be drawing data over time you would draw all the relevant data while backgrounded out at once when the app resumes.