MacOS: Identify between NSMenuItem shortcut typed or mouse pressed - swift

I have Spritekit game for the Mac. It includes NSMenuItems in the menu as with normal Mac applications. Now the thing is that
if I choose an action from the menu with the mouse, the Spritekit game starts executing right away and some of the subsequent animation is missed.
if I choose the same action with the keyboard shortcut, the game starts executing right away but none of the animation is missed since there is no delay switching from menu animation to game animation.
Is there some way to identify if the IBAction sent by the menu item is being triggered by the keyboard equivalent or by mouse? I want to add a start delay to the game animation if mouse is used and no delay for key equivalent.

The type of the current event can be obtained by reading NSApp.currentEvent.type.
See NSApp.currentEvent and NSEvent.type for details.

Related

Start game if anything but a UI Button is touched

I'm building an iOS game and I had the game set up to start whenever the user first touched the screen. This was working out perfectly fine for testing until I added menu buttons as an overlay that would disappear when the game starts. Obviously I can no longer just check for user input, because the game now starts even if I tap a UI button.
I tried adding an invisible UI panel with a box collider behind my UI buttons with an OnPointerDown that would start the game, but for some reason it was acting very inconsistent and would sometime require 5+ taps to start the game. It also wouldn't start if you tapped on the player because it would hit his collider instead.
Is there a better way to do this?

Cursor not showing

As we develop a little game with defold (defold 1.2.102 | defold editor 2) we encountered the following problem:
When we start our game the window shows everything we built properly and there are no build errors or error console logs. However there is no cursor. Neither on the levelscreen of the game nor on one of the other monitors. We added a keypress input for testing the buttons and it worked properly, but the problem remains: Where is our mouse pointer? Do we have to add or adjust it somehow?
Thank you for your help!
Are you running your game in fullscreen mode? Defold always hides the mouse pointer while running in fullscreen mode. You can add a game object with a sprite (or even better a gui box node) and let that follow the mouse coordinates and use it as a custom pointer for your game.

UE4 Enabling Mouse During Play?

I'm extremely new to UE, and doing a few easy tutorials to get started, so I don't exactly know the correct terminology to use to help me find what I am looking for... Anyway, whenever I hit play and the game starts, my mouse disappears and I am only able to use the input that I set up; so my question is, even though I do not need mouse input for movement, as I am using WASD, how do I keep my mouse unlocked and available to move around without being locked to the camera?
When you hit play and the game starts, your mouse gets captured by the game to control the camera. If your play button is set to play in the viewport, you can release the mouse from the viewport by pressing Shift-F1. The game will still be running, but input (including from the keyboard) will be suspended and you can interact with the editor.
You can also change the default behavior of how the mouse is captured and it if is constrained to the viewport boundaries. To see these options, go into the project settings (settings button above main viewport/project settings...). On the left side of the project settings window, select 'Input' under the Engine heading. On the right side will be some mouse preferences that can change its behavior.
For instance, to allow the mouse to travel outside the viewport, change 'Default Viewport Mouse Lock Mode' to 'Do Not Lock'. I don't recommend this, but you might experiment with these to get a feel for what they do. Also, you might look up these settings in the Unreal documentation for more detail.
There are 3 blueprint nodes that change the input method:
Set Input Mode Game
Set Input Mode Game and UI
Set Input Mode UI
You want a combination of the second one and a "Show Mouse Cursor" node. However, if you are making an FPS and you use the mouse to look around, you may lose that ability with the second node above. It comes down to what your game is and how you want to use the mouse.
I had the similar issue. So I did something like this in Level Blueprints to achieve what I want.

simple UI menu and canvas for DK2

I am using Unity 5.1.2p3 with DK2 SDK 0.6.0.1 and I understand from this post that Screen Space - Overlay is not supported in Unity VR. It is recommended to use Screen Space - Camera (which in my case does not work) or World Space (which I am using now) but I need someone to help me understand how I get simple menu with buttons and toggles to show as a still image and how I can make selections and button presses with my mouse cursor.
I have created a menu for my app, with 4 toggles and 1 button. When I check the Virtual Reality Supported option with the Oculus being in Direct Mode and Canvas being in World Space, I can see it in VR, but I cannot see/find my mouse cursor to tick one of the toggles.
When I take off the headset, on my monitor's Game View tab, I can see and even use the mouse and select a toggle. Obviously, I have to keep the headset steady, so in my Game View, things do not shake!
Another thing I notice is that the VR camera is the same as the Main Camera in the Unity Hierarchy, but when I take off the headset and move it around, the position of the camera does not change, only looking up and down and around is reflected.
How do I simply do a static menu like a 2D surface that does not move in VR and a user can use button presses and muse clicks with the headset on? What settings are required for this way of doing UI and canvas stuff? There are 2 attachments, showing my current settings...
Are you specifically wanting to use the mouse? If you look through a blog entry I wrote below, it will show you how to use Gaze looking to trigger menu buttons:
http://talesfromtherift.com/vr-gaze-input/
You can achieve this by some code I list there that raycasts from the center of the screen and if it hits any UI, it will trigger the correct events and make it clickable by button (or by time).

Changing Scene in Pause Mode Cocos2D

I currently have a Pause scene in which the animation is a closing door. (Added to the gameworld via add layer). If I choose resume, it will open up and resume the game.
I've also a Quit button in which player will go back to the game menu. I like the
effect to be when quit is selected the door will open to the game menu. How do I go about doing this?
I created the same animation onto the game menu. So when I replace scene the animation will
be played from the game menu.