How do I make a fade out animation for the minimize button? - animation

so I made a fade out animation for the exit button, but I'm not really sure how to do it for the minimize button. Does anyone have an idea on how to do it?
So, for the exit button I used a timer which would get activated as you press the exit button, and I used the following code:
if (Opacity <= 0)
{
Application.Exit();
}
Opacity -= .2;
I tried doing something similar with the minimize button as well, except I used "WindowState = FormWindowState.Minimized;" instead of "Application.Exit();". It worked, it did fade out when I minimized the app, but I couldn't open the app back, it literally worked like an exit button except the app stayed open.

Related

MFC: how to show a welcome dialog first?

When launch the program, I want to show a welcome dialog first before showing the main window. My current approach is like below.
BOOL CMyApp::InitInstance()
{
...
// The one and only window has been initialized, so show and update it
m_pMainWnd->ShowWindow(SW_HIDE);
//m_pMainWnd->UpdateWindow();
// call DragAcceptFiles only if there's a suffix
// In an SDI app, this should occur after ProcessShellCommand
CWelcomeDialog welcome_dialog;
welcome_dialog.DoModal();
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
Towards the end of InitInstance(), originally it uses (SW_SHOW). At first, I try commenting it out but it still shows. So I change to (SW_HIDE). It works but has unpleasant visual artifacts. Is there way to stop showing the main window as early as possible?
Another issue is that when I hide main window and show the dialog, the dialog is not in the center position of the main window.
In general, how to implement a welcome dialog and to show it well-centered before anything else?

Creating a pause menu in Xcode SpriteKit

I have been developing by game for some time now and I am now trying to code in a pause menu. I have been looking through forums and videos but i still do not understand how to implement in a pause menu. I have a little pause button in the top left corner which i want to click to pause. Then it to overlay a menu, such as changing the z position of items so they are now visible. And then there be buttons such as resume and main menu which respectively do what they are called. I am still quite new to coding so any help would be appreciated. I am working with falling objects and a moving player so if i need to freeze them all, then unfreeze once resumed that might be a solution I am not sure. Thanks :D
I've tried various ways to do this, but not found a satisfactory method that works for any app/game. A lot of it will depend on how your game works. As a starting point, you probably need to look at someway of pausing the SKScene - this should halt a lot of the animation (but you may have to do extra work).
You could add some kind of blur effect or overlay and then add an unpause button and then pause the scene. Touches will still be detected when paused, but you won't have any animation or updates happening after the pause. The following code should work to pause the scene.
let pauseAction = SKAction.run {
self.isPaused = true
debugPrint("Paused")
}
self.run(pauseAction)
The reason to pause the scene in an action is that any addChild calls won't be processed if you set isPaused directly. actuallyPaused is just a bool variable to keep track of wether the scene should be paused or not (if the parent view is un-paused, the scene would also be un-paused). Btw, You do not need to use an action to set isPaused to false.
You probably also should look at implementing observers for
NSNotification.Name.UIApplicationWillResignActive
NSNotification.Name.UIApplicationDidEnterBackground
NSNotification.Name.UIApplicationWillEnterForeground
as you will also need to know when your game has been sent to background either via control center or the home button.

Is there a way to avoid multi click on SVG

If you animate an <svg> on click event begin="item.click" and the animation duration is for exemple 5 sec. If you click before the end of the animation, it becomes a big mess.
Is there a way to avoid click until the en of the animation ?
Here is a pen I've done. I you click several time, it's a mess !
The restart attribute can be used to prevent an animation being restarted when it's running. Try restart="whenNotActive"

Managing Scroll with touch events in SmartWatch 2

I have this:
#Override
public void onTouch(final ControlTouchEvent event) {
int action = event.getAction();
if (action == Control.Intents.TOUCH_ACTION_PRESS) {
Log.d("Touch Test", "Touch: Press at " + event.getX() + " - " + event.getY());
}
else if (action == Control.Intents.TOUCH_ACTION_RELEASE) {
Log.d("Touch Test", "Touch: Release at " + event.getX() + " - " + event.getY());
}
}
Basically, its working but for single presses. Let me explain.
If you press the screen and release on same position, lest call it a "click" both logs get fired, the Press first, then the release.
But I want to manage scrolling, so, if I press, then move my finger, and release in other place of the screen, I only get the press event fired.
I want to know start position when pressed and end position when released, so I can scroll the layout!
How can I achieve that?
Thanks!
But I want to manage scrolling, so, if I press, then move my finger, and release in other place of the screen, I only get the press event fired.
I think that's because you are doing a swipe event, so on release it will trigger the Control.Intents.SWIPE_DIRECTION_[UP|DOWN|RIGHT|LEFT] action and not the Control.Intent.TOUCH_ACTION_RELEASE.
If you don't need the swipe events you can remove the Swipe intent from the manifest. Otherwise you should consider to use the SWIPE intents to manage the scrolling. The main difference is that with Swipe events you don't get the magnitude of the swipe you only get the direction, but that should be enough for the most cases.
The SmartWatch 2 is not functioning consistently in regard to the touch detection. Thus, not every TOUCH_ACTION_PRESS event is followed by a TOUCH_ACTION_RELEASE event (as it is the case for the SmartWatch 1), but it can be followed by a SWIPE event, for example. Also, the SWIPE events are too easily triggered, so any attempt to implement the scrolling as you want it, would not be successful.
Best thing to do is to use the Gallery and ListView for smooth scrolling.
As the others said, the "scroll" as is, is not supported.
The SDK is good, but lacks some functions. I hope Sony update it in the future, however, it may be too late now.
This is what I ended doing on my app:
I used a TOUCH_ACTION_PRESS to save the press action in a global object, then, I used the SWIPE event to get a direction.
In the Swipe routine, I ask if the PRESS event has been made, and if so, I do the "scrolling" with the SWIPE direction.
To get a better feel, I ask where the PRESS started on the Y axis, so, if lets say the pressed started at bottom of the screen, and the swipe was swipe up, I move the view more than if the press started at half screen.
It is not very smooth, but, I think there is no better way to do it. The other option is to use on screen buttons, but I do not like them.
I haven't fully understood this yet but I am getting three sets of events when I have not got any clickable objects:
For simple taps: onTouch(PRESS) followed by onTouch(RELEASE)
For swipes: onTouch(PRESS) followed by onSwipe()
Unfortunately for very short swipes, or slipped taps:
onTouch(PRESS) only
It appears to differ if you have clickable objects. This is the pattern I get when I do:
For simple taps: onTouch(PRESS) followed by onTouch(RELEASE) then onObjectClick
For all swipes: onTouch(PRESS) followed by onSwipe()
Since onSwipe only gives the direction and not the event (with location), I cannot find a satisfactory way of handling this except to process all events when I get on onTouch(PRESS) and then undo the tap operation if there is a follow up onSwipe. Depending on what you are doing this undo could be easy or really tricky - but if fast enough the user will never notice...
Turning off swipe in the manifest doesn't help - you just lose the onSwipe events and sadly don't gain the onTouch(RELEASE).

Autohotkey Mousemove Wrong Monitor

I'm using mousegetpos to get the current mouse position. I click somewhere else. Then I try to restore the original postion with mousemove. The mouse moves to a different monitor. I tried the alternative method dllcall, with no success. How do I move the mouse back to the original monitor?
It's easier to help if you post your code - then people can see where you're going wrong.
This works fine for me when pressing the Ctrl-T hotkey:
CoordMode, Mouse, Screen
^t::
MouseGetPos, x, y
; Do Stuff Here.
MouseMove, x, y
return
The CoordMode, Mouse, Screen line sets the coordinates relative to the entire screen rather than the active window. I've tested this on my multiple monitor setup and the mouse goes back to the original location every time, even across monitors. Let me know if it's not working for you.
Also, just to make things a little smoother, you can set the mouse speed to '0' before moving the mouse with:
SetDefaultMouseSpeed, 0
This makes the mouse appear to move instantly which looks a little cleaner in most scripts.
I can confirm that Gary's answer works perfectly for anybody else out there having similar problems. Thanks, Gary!
I was myself having a problem like this with Breakaway Audio Enhancer...
For anybody that uses or knows Breakaway, you have to double-click on the toolbar (in the taskbar) to mute it. The way Breakaway works with the sound pipeline other standard AHK mute scripts won't work, so moving the mouse to the toolbar and double-clicking is really the only method of muting. I wanted Caps Lock to mute (or unmute) audio and preferably have the mouse return to where it originally was.
I've had countless problems trying to get this to work with multiple monitors until Gary's post, so here is my solution for anybody else having similar issues:
Capslock::
BlockInput On
CoordMode, Mouse, Screen
MouseGetPos, xpos, ypos
MouseClick, left, 42, 965, 2 ;change the co-ordinates to match your system
MouseMove, xpos, ypos
SetDefaultMouseSpeed, 0
BlockInput Off
Return

Resources