Moving an object - Forum

Forum Navigation
Climate strike banner
You need to log in to create posts and topics.

Moving an object

I'm trying to produce a program that moves specific images across the screen, from left to right.

example:
PRESSbutton 1 and IMAGE 1 moves 1 point across.
PRESS button 2 and IMAGE 2 moves 1 point across..
PRESSbutton3 and IMAGE 3 moves 1 point across....

etc. etc..

All images stay on the same 'line' but move only one point everytime their respective button is pressed.

Now, I know this this simple to do, BUT it struggles when multiple buttons are pressed at the same time.

The program is like a 'game' whereas the quicker you press your button, the quicker the image moves across the screen.

Can anyone think of a way to solve issue that I'm having where the images don't move when more than one person is pressing their button?

 

Thanks

@mbpitt

BUT it struggles when multiple buttons are pressed at the same time.

When you say "multiple buttons are pressed", are you talking about a "touch screen where multiple people can tap on the buttons" ?

Can anyone think of a way to solve issue that I'm having where the images don't move when more than one person is pressing their button?

You did not say how many such buttons there are ... but try this first ...

In each Button's click-event code, DisableObject all the relevant Buttons BEFORE you invoke the code to move the image in question ... when completed, EnableObject all the Buttons again.

If you still can't Disable all the Buttons fast enough, have a (transparent) Container object that covers all the Buttons ... have its normal z-index be such that it is at the bottom of the z-index pile ... then, instead of Disabling all the Buttons, just change the z-index so it is on the top of the z-index pile ... it will prevent the taps/clicks from reaching the buttons.

 

Note: I recall reading somewhere that some touch-screen device systems "pause after a single touch" to determine if there is going to be a second touch (i.e. simulated double click) ... this may prevent your code (even the first line) be given control during the pause period ... make sure the Buttons do not have a double-click event code.

 

MULTIPLE BUTTONs:
these are physical buttons....that people press and each button is allocated to a key (1-8)

There are eight buttons.

 

Gaev,

Do you mean disable the button then run script, then enable button again.

Do this for every button?

@mbpitt

these are physical buttons....that people press and each button is allocated to a key (1-8)
There are eight buttons.

This appears to be some non-standard configuration ... I was under the impression that you were referring to the PushButton objects.

Please ...

- clearly describe the physical connection of these "buttons" to the device (phone, tablet, computer) ... wired/usb/bluetooth ? ... special software/driver to pass the button presses to a key code ?

- post the code you have for moving each object by one pixel

- tell us where this event-code is defined ?

Depending on the configuration, there might be some delay between the press of one of these buttons and the signal being passed to your App ... in which case, there would be nothing you can do inside your App.

Do you mean disable the button then run script, then enable button again.

The Disable/Enable commands are part of the script.

Where you have the commands to "move the image object", just insert the DisableObject command for each "Button object" ... and at the end, add the EnableObject commands

Do this for every button?

If there is a MoveObject command for each "Button", then yes ... but you can place these 8 commands inside a SubRoutine ... and just call this subroutine from each of the "Button event sections"