JBOX2d: restart a game - refresh

can anyone show the correct code to reset a game when using physics engine (JBOX2D)?
I am working on a game using Processing and I am unable to reset the game so that the user can play another round.
Thanks in advance

A google search will bring you to this page:
JBox2D with BoxWrap2D Tutorial
from which I can see that doing
physics.destroy();
physics = new Physics(this, width, height);
and recreating your objects will reset the sketch..

Related

Multiplayer Spawning in UE4 blueprint

i want to create a local multiplayer game for 2-4 players.
It seems like i have made a mistake or it is a bug. I tried different tutorials but i dont get my mistake. I posted the same question in the answer hub of unreal, but i didn´t get a response. Here ist my gamemode and the spawning function:
GamemodeSpawning
My Pawn is called Physics Ball BP. The default spawn in the gamemode is disabled. The default value of the variable "Max Player Amount" is 2. "Player Start Array" contains the PlayerStarts. The PlayerStarts have the tag "0" and "1". This is my viewport before the start:
Viewport
This is my viewport if i press Play: ViewportPlaying
I think i just missed something basic, but i cant figure out what i´ve done wrong. I hope you can help me.
best regards chris
Not sure if you did it on purpose but you uploaded the same screenshot of your viewport twice. Maybe edit your post, and upload the right ones.
But maybe the problem your having is because you forgot to plug your Index variable into the Player Int variable in the Spawn Actor node?

QT/QML/C++ media player

I have implementeda C++ media player using QT and have variable can access functions like play(), pause() and stop() using QMediaPlayer *player;
So the issue that I am having is that of fastfowarding my player.
I used a comboBox and a Slider to play the video on fastfoward but having troubles connecting it to the rate at which the video is playing.
Please assist me. I can attach my code for you to see what I have done so far, but I am looking for a function/method etc.. that can make player to fastfoward. thank
QMediaPlayer::setPlaybackRate(qreal rate) is what you are looking for. Set it to 2 for twice as fast, for example.

pause/ play a game in cocos2d android?

How to pause a game in cocos2d android? I searched many tutorials but i did not found anywhere.I tried below code, it is working when paused from game scene.But it not working while resuming the game from pause scene
in gameScene :
CCDirector.sharedDirector().onPause();
in pause Scene :
CCDirector.sharedDirector().onResume();
For pausing game scene I use:
CCDirector.sharedDirector().pause();
And for resuming:
CCDirector.sharedDirector().resume();
Try it with these functions. :)
Thanks for your reply. I used the same thing.But it wont stop schedulers and actions.
But finally i got the way we have to pause.
1.To pause we have to use pushScene() method as follows:
CCScene pauseScene = CCScene.node();
pauseScene.addChild(new PauseLayer);
CCDirector.sharedDirector().pushScene(pauseScene);
When you have done this, gamescene will get stored in the stack and now running scene will be pause scene.
2.To resume we have to use popScene() as follows:
CCDirector.sharedDirector().popScene();
3.If you are moving to LevelSelection form pause then along with above lines use these lines also:
CCDirector.sharedDirector().getRunningScene().removeAllChildren(true);
CCDirector.sharedDirector().replaceScene(levelSelectScene);
Declare a BOOL variable, then when you detect user pauses game, make this variable to NO and in your update method put this as a condition above to the code you want to pause on your game paused.
-(void)update:(ccTime)dt
{
if(isGameNotPaused)
{
// your code
}
}

Player Disconnect Issue GKMatch and Gamekit

i am working with cocos2d game with GameKit. I am creating match with 2 player using GKMatch. All thing is working fine for me but When one player enters the background state or pressing home button , then player is disconnected. I want to run GKMatch instance in background also. Please help me.
Thanks in advance.
I don't think that's possible, after all "background" means the player stopped playing.
While the programming guide might not mention that explicity, it does one thing, namely automatically logging in the player when the application enters foreground, which to me indicates there's simply no player GKMatch could be connected with while the app is in the background.

cocos2d game reset problem

I have a cocos2d game, and after I exit the game and start it again, it starts at the exact same point it was before closing.why this is happening??and not only this, my game is landscapemode but when i start it again from simulator it comes in potrait mode,not it landscapemode like first time.
Is there any way to prevent this?
Anyone will come to rescue me???
From iOS 4.0, there are new options for "info.plist" file.
If you do not want to add multi-tasking(running in background), just add it.
You can add the option by just clicking and checking in your game project's "info.plist".
And rotation setting is on your "RootViewController.m" file.
You can change your app direction by just changing return value.
I hope your game will work well.