How do I see when the game is unfocused?

Get help using Construct 2

Post » Fri Nov 13, 2015 2:38 pm

I am making a game to be hosted on Newgrounds. The game uses mouse control, and what I want is when the player clicks outside the game's area, the game should be paused.

I already got the logic part in my event sheet about game pausing, but is there any way in Construct 2 to see if the player has left click/right click outside the game's window or if the game has lost focus?
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,459

Post » Fri Nov 13, 2015 6:09 pm

in the browser plugin there is a "on suspended" and "on resumed" conditions - might be what you are after ?
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,812

Post » Sat Nov 14, 2015 1:12 pm

@RamPackWobble Ah, this works when the player changes tabs, etc., but there is one problem left unresolved - suppose you run the game (either preview or exported to HTML5 and upload to Dropbox) and you right click on the black area that is outside the game's window, "on suspended" won't be fired in this case. Also, the right click contextual menu will pop up and the game will not be "focused", meaning all the keyboard events will not be fired.

What you suggested works to a certain extent but it does not solve the whole problem fully. Nevertheless, thank you for your answer. :)
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,459


Return to How do I....?

Who is online

Users browsing this forum: el3um4s, Ryan Kocourek, TylerJS and 13 guests