Ignore D-Pad Commands

I'd like to use the crank for player movement and ignore D-pad up/down commands. The 'ignore' & 'listen' functions don't seem to allow granular control over the suite of input options and I don't see any way to cancel the event.dy input. Is there any mechanism for mitigating with using goto to offset?

1 Like

I solved my own problem with a few lines of code in the player update event.

Note that my game restricts x-axis movement with 'hidden' wall world tiles, but could be easily adapted for anyone looking to accomplish the same goal (force use of crank or other input mechanism for player control):

	if cancelDPad==0 then
		if event.dy!=0 then
			realY = event.y
			realY -= event.dy
			cancelDPad = 1
			goto event.px,realY
		end
	else
		cancelDPad = 0
	end
	call "calculateMove"
end
2 Likes

One caveat

You'll also need to escape your d-pad handling to allow for manual movement. In my case, I'm using a custom physics engine to control y velocity. See use of the "calculatingPhysics" variable below:

  if calculatingPhysics == 0 then
  	if cancelDPad==0 then
  	  log "event dy = {event.dy}"
  		if event.dy!=0 then
  			realY = event.y
  			realY -= event.dy
  			cancelDPad = 1
  			goto event.px,realY
  		end
  	else
  		cancelDPad = 0
  	end
  else
    calculatingPhysics = 0
  end if
	call "calculateMove"
end
1 Like

Hello, I'm new to coding and don't quite understand how this code works. I tried copying it in to my game but the d-pad still moved the player when I tested it. Is there something else I need to do?

hey, it depends on exactly what you want to do. op here was doing something VERY specific. If you want the player to never move from spot (4, 3) for example, you would just need a really simple thing like this:

on update do
  goto 4,3
end

there are lots of other things you could do as well. if you make the character transparent, it won't matter where they are so dpad moving will effectively be ignored. or you could just box in the player with solid tiles.

What OP ended up doing was checking event.dy, which tells you if the last update was an upward or downwards movement (dy probably means something like "delta for y-axis") and uses goto to tell them to undo that movement.

If you would like further help, you should make your own thread explaining your specifics.

1 Like