Is this a problem with flash, or something I can fix? [SOLVED]

ConquistadorBob

  • Posts: 21
In My Game you control a guy with WASD, and you use the mouse to click on and shoot things. The problem is if you accidentally click outside the flash window, you can't control the game until you click back in the window. I understand this might not be able to be fixed. However, what also happens is that whatever direction you were walking in before you clicked out, it keeps you going in that direction until you click the button for that direction again. For example, if you accidentally click out of the window while holding W, it makes you keep moving up until you click in the window and hit W again. Is there a way to make it so that if you click out of the window on accident, it just stops the player character? 

« Last Edit: May 29, 2020, 02:37:21 pm by ConquistadorBob »

Luyren

  • *
  • Posts: 2335
There's a focus event. You can set your actor's speed to 0 or call a custom event to stop it when the game loses focus. I'm not sure if it works on flash/html5, but worth a shot.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

ConquistadorBob

  • Posts: 21
There's a focus event. You can set your actor's speed to 0 or call a custom event to stop it when the game loses focus. I'm not sure if it works on flash/html5, but worth a shot.

This fixes some of the issues, but not all of them. Maybe I am just missing something. I have this in my player moment script because that is where it is most relevant, and it allows me to mess with the player movement more easily. I pause the game which stops all the enemies and all, but the reason I simulate a button release for all the movement buttons is because that stops the player from continuing to move in one direction when they come back. The problem is, now when you come back  it wont let the player go in the direction they were going in until they press that direction's button again. If they were going up with W, it lets them go any other direction except up, until they click W and release W again. My thought was to simulate that action when the player comes back. So in the, When Gains Focus Event, I made it simulate a press and release of each button. But that does nothing at all to change the problem. Like literally makes no difference. I think it might be a problem with my movement event??? Here is my movement.


If you can't find anyway to help me out of this mess I got myself into, that's ok. You've already helped a lot.

Luyren

  • *
  • Posts: 2335
I can't think of anything. All flash games behave that way.
I do suggest you test on HTML5 and see if this happens as well. Most if not all game portals accept HTML5 games, and Flash itself will no longer be suported on browsers by the end of the year, if memory serves. So you are better of worrying about issues on the proper platform.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

ConquistadorBob

  • Posts: 21
I can't think of anything. All flash games behave that way.
I do suggest you test on HTML5 and see if this happens as well. Most if not all game portals accept HTML5 games, and Flash itself will no longer be suported on browsers by the end of the year, if memory serves. So you are better of worrying about issues on the proper platform.
I have not been using HTML5 because I was lazy and did not want to make OGG sounds and stuff like that. But I have now done so. and I do not have this problem in HTML5.  But for some reason I have a different problem. So like, my title screen has music, and in Flash it automatically plays when the title screen is created. But in HTML5, it only plays once I click anywhere on the title screen. It's like the game will do nothing unless I click on it first in HTML5. I did some looking up on the forums here, and a bunch of people said they had similar issues, but no one replied with a solution.

Luyren

  • *
  • Posts: 2335
I have one game and a few demos up on itch.io and I do not have this issue, so I can't comment on it, nor do I know if there are ways to prevent that from happening.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter