How to disable a button!

Hello! I’m gonna show my way of disabling a button in makecode (if you don’t want you character going up and down)


(just follow picture if you dont wanna follow text form :smiling_face_with_tear:)

First is to get the [On button pressed/released] block in controller, Then get [If true/false] block in logic (set it to true). Then get the [Move sprite with buttons vx 100 vy 100] click on the plus to access the VY and VX thingy. Set both of those to zero (duplicate). Then get the same button block but set it to release, Get the VX/VY block and set it back to 100.

Example below!!
BEWARE that there is a small bug where if you do press up and down at the same time you will end up moving up or down!!

ScreenRecording2024-10-09112145-ezgif.com-video-to-gif-converter
Hope this helps :princess:

Or you could Set VY to zero in this context it shares the same purpose and is More efficient

Also the Booleans ( the Blue True blocks) don’t do much without other stuff defining them its nice for debugging or getting through menus but from a players point of view it does nothing

3 Likes