I have a server and a client. But when ever I start moving the game window, it stops executing code until the window stops moving,causing a connection timed out because the server or client stopped responding for a while.
What do I need to do in order to make the game always run code, even when the game window is being moved?
This is a known issue with XNA games, and there are several ways around it.
One way is to move a fake window frame, which isn't the game window really. Game window will then fit into the fake window's client area, only pausing execution for insignificant amount of time.
Other ways may involve use of windows hooks, unfortunately, that is all I can say about it. Personally, I recommend the approach with fake window.
Related
I'm using Game Center to create a real time match and I am working on a restart button. When the game ends it takes you to another screen that shows you everyone's score and on that screen there is a restart button. If someone presses it their name will turn green and if they leave the game then their name will turn red. Once everyone has either hit restart or left the game then the game will restart by presenting the game scene again.
The thing is though, they're all doing this at slightly different times and sometimes one of the devices will send a signal to the other devices before those other devices have made it to the game scene and so the message isn't being interpreted and is just lost. So my question is, is there any way to make sure that all the players go the the next scene at exactly the same time?
You can have a synchronization step after the scenes have loaded. You will never be guaranteed everyone loads at the same time/rate.
So,
1-signal everyone to load,
2-everyone works on loading,
3-don't show the scene or render anything relevant yet,
4-wait for everyone to send a ready signal (some people may have to
send the ready signal repeatedly to work around boundary loading
issues),
5- everyone gets a ready signal,
6- users can now display the scene,
7- do one last check by sending another 'ready signal' to everyone
(again some may have to broadcast multiple times),
8- with the last signal received from everyone confirmed, the game can begin.
This redundancy is to make sure the users are able to broadcast appropriately before and after showing the scene. Of course, There is a LOT of implicit error checking and timeout checking during this process, if there is a stray user unable to broadcast, then they may just need to be considered for booting off the match after a given amount of time so the other players can still play.
Also this is my best whack at syncing things as much as possible to where you can try and make sure signals are not lost. Do a synchronization procedure, then start sending relevant signals.
You CAN NOT guarantee exact timings of next screens for different users, you can just get them as close as possible.
The important part is NOT the screen display but rather making sure all users are in the correct STATE to receive the next set of data broadcasted by the others.
Different internet speeds and different device speeds will always hinder perfect visual synchronization.
I am working on an app for a physical boardgames I have produced in the past. Everything is working fine (for now). But the app "freezes up" when the code for the computer "thinking" kicks in.
This is understandable, the computer needs time to make it's turn.
My question is. Is there any way I can simultaneously set an animation to run (like a progress icon), while the computer continues to "think" over it's turn?
Thank You.
You can't make something like a progress bar which indicates exactly when the computer will finish 'thinking' exactly because the computer does not know when it will be done.
However, you can create an animation that will run as long as the computer 'thinks'.
In your Gameplay file in Spritebuilder, create the animation that you want shown while the user waits. Chain this animation timeline to itself. Let's call the default timeline animation 'default' and the 'computer is thinking' timeline animation 'think'.
Inside the method you use to start the computer's turn, add a line of code that warns cocos2d to run the 'think' animation sequence; it would also be good to make any user interaction with the game impossible at this time (example below is given in Swift):
animationManager.runAnimationsForSequenceNamed("think")
self.userInteractionEnabled = false
Since the 'think' timeline was chained to itself, it will run in an infinite loop, only stopping once cocos2d receives an instruction to break that timeline and start executing another one, so, just inside the method you execute once the computer's turn is over, add these two lines in order to stop the 'think' animation from running and to enable user interaction once again:
animationManager.runAnimationsForSequenceNamed("default")
self.userInteractionEnabled = true
Not knowing where you are building your actual game in, using different threads is the way to go. What are you building your game in? Which language, framework, platform?
I've seen some software which can detect whether or not a form is visible to the user. This might include being minimized, another screen covering it up, monitor turned off, and even when on remote desktop, knows when the remote desktop view is not visible. I'm guessing it has to do with whether or not anything is being drawn in the application. Perhaps video drivers can provide this information?
How can I make my application to detect this? Is there a Windows message I can monitor for this?
For the record, the mentioned software is one which streams multiple surveillance cameras in real-time (RTSP) which uses this ability to the advantage of pausing streaming when the screen isn't visible.
Most of the conditions do not have window messages associated with them, so you have to detect the conditions manually.
Use the TForm.WindowState property, or the Win32 API IsIconic() function, to detect your window's minimized state. You can also catch WM_SYSCOMMAND messages looking for the SC_MINIMIZE, SC_MAXIMIZE, and SC_RESTORE states.
Use the Win32 API EnumWindows() function to loop through all top-level windows, calling GetWindowRect() on each one, to detect if any areas of your window are not covered by other windows. To account for z-ordering, you may have to use GetTopWindow() and GetNextWindow() to iterate the z-order to see which window is on top of the other window.
Use MonitorFromWindow() and GetDevicePowerState() to detect the local monitor's power state. You can also catch WM_SYSCOMMAND messages looking for the SC_MONITORPOWER notification.
Detecting the Remote Desktop state is a bit trickier. You can use ProcessIdToSessionId() and WTSQuerySessionInformation(WTSIsRemoteSession) (Windows 7+) or GetSystemMetrics(SM_REMOTESESSION) to determine if your app is running inside of a Remote Desktop session, but I don't think you can detect whether the remote display is on/off (although WTSQuerySessionInformation() can query the remote display's resolution and color depth, and even if the session is locked/unlocked).
I'm guessing it has to do with whether or not anything is being drawn in the application.
For partially obscured windows, Canvas.ClipRect (which is equal to the rcPaint member of PAINTSTRUCT or the result gotten from GetUpdateRect) will be the portion of the device context that has to be redrawn. GetUpdateRect can be called outside a WM_PAINT handler, Canvas.ClipRect only within.
But if you could of would solely rely on paint messages being sent, I am not sure. I think Remy's suggestions are more robust. Or a combination of all.
I work on software that keeps track of time (C++/MFC), and when time is up (after a handful of warnings as the time limit approaches), we need to bump the person off of the computer.
Works great with Windows apps, however, it seems that a fair number of games, typically when they are in full screen mode, can be played even after we've done our work to hide other windows and/or swap to another desktop.
I know nothing about DirectX, and since I know nothing about it, I'm eager to blame it. :-)
My assumption is that when in some kind of "DirectX" mode, the game is interacting with the hardware and whatever the Windows API is doing, the game and the video hardware could care less.
The problem is that I have unhappy parents who thought our software was going to be effective and it's not.
DirectX/Game Guru's, Is there a way that my Windows App can give the game "the boot" when time is up, forcing the Windows desktop to be displayed, pausing the game, or at least detecting that we're in a hopeless situation with the display mode being in full-screen DirectX mode which can't be programatically switched out of?
I am getting a strange behavior when I reopen my app after it loses focus from the home button. On the simulator the app screen goes black for 5 seconds or more before the application is resumed. On the test device, the application either does the long delay or quits entirely and resets to starting state. I have put NSLog debug comments in the “applicationWillEnterForeground” and “applicationDidBecomeActive” but these only appear after the long delay so I will assume for now that nothing in these functions cause this delay.
I am using the following components in my program:
* a Tab Bar Controller
* 2 Timers, the Map kit
* IP socket streams
* 24 ViewControllers strung together on a storyboard.
* quite a few background images and image buttons
I would happily post code if I know what parts of the program was causing this error, but as it is I am clueless. Has anyone else experienced this type of error? Do any of the components I have listed have a history of causing similar errors?
I was quite far in development when this bug was discovered and I did not test for loss of focus via home button during the incremental development process. Other, smaller projects (which used sockets and timers) did not suffer from the same bug on the same test hardware.
I am using “applicationWillResignActive” to disable the timers, and close the streams. I am using “applicationDidBecomeActive” to restart the timers, and reopen the streams. The delay is occurring before “applicationWillEnterForeground” and “applicationDidBecomeActive” is run. Further more I tried disabling the code that initiates the streams and timers, but this did not have any effect on the bug.
I am using xCode4.4.1, ios6, and am building exclusively for iPads.
It's possible that the debugger is playing tricks with your mind regarding when it shows that you hit a breakpoint and the code execution of applicationWillEnterForeground. I suggest you commit your most recent code to source control and start deleting sections one at a time till you see the behavior go away.