chrismaltby / gb-studio

A quick and easy to use drag and drop retro game creator for your favourite handheld video game system
https://www.gbstudio.dev
MIT License
8.56k stars 471 forks source link

Using run and Item: attack simultaneously #678

Open TheRetroRoomRoo opened 3 years ago

TheRetroRoomRoo commented 3 years ago

Describe the bug I would like to be able to use attacks as well as running simultaneously similar to the fireball powerup in the Mario games

To Reproduce Steps to reproduce the behavior:

  1. Attach script to button. Item: attack on press
  2. Also attach script to button. Player speed 2 on press

Expected behavior Run when the button is held, attack when the button is tapped.

Platform (please complete the following information): Gbstudio 2 beta 4

patrickmollohan commented 3 years ago

I do think we need On Press/On Hold/On Release tabs for scripts to properly handle this. You can kinda get away with using a timer script and two variables tracking the button state to detect if a button is pressed/held/released, but due to issue #629 your sprite will fly off screen if you change the movement speed while the sprite is off tile.

TheRetroRoomRoo commented 3 years ago

I do think we need On Press/On Hold/On Release tabs for scripts to properly handle this. You can kinda get away with using a timer script and two variables tracking the button state to detect if a button is pressed/held/released, but due to issue #629 your sprite will fly off screen if you change the movement speed while the sprite is off tile.

I wouldnt mind at all if they both fired off at the same time without an "on hold".. my problems is that they do not work at all together. You have to choose one or the other. Either run or attack.. Not both.

RichardULZ commented 3 years ago

You can not attach 2 scripts to one button, it will overwrite the last attachment. You must make the code for both functions part of one attached script, just fire a projectile, then set speed, no need for 2 attachments.

With 2.0 beta 4 and 5, attach scripts also override the default button behavior, so you can disable actor movement like 1.2 https://github.com/chrismaltby/gb-studio/blob/v2beta/CHANGELOG.md#200-beta4

As mentioned with #629 setting player speed while mid tile is buggy in all 2.0 betas currently.

TheRetroRoomRoo commented 3 years ago

You can not attach 2 scripts to one button, it will overwrite the last attachment. You must make the code for both functions part of one attached script, just fire a projectile, then set speed, no need for 2 attachments.

With 2.0 beta 4 and 5, attach scripts also override the default button behavior, so you can disable actor movement like 1.2 https://github.com/chrismaltby/gb-studio/blob/v2beta/CHANGELOG.md#200-beta4

As mentioned with #629 setting player speed while mid tile is buggy in all 2.0 betas currently.

It unfortunately doesnt work. Only the first action listed in the attach script works. That even with them sharing 1 attach script to button. The run just gets overwritten.