How do I get the get tile movement with drag and drop?

0 favourites
  • 6 posts
From the Asset Store
320 high-quality cinematic sound effects for trailers and game scenes.
  • C3/Mobile

    I'm attempting to make a simple sorting game.

    The Yellow-ish guy is the player. The player grabs the blocks above and moves them between the green guides.

    I need the player to move back and forth in a straight line, between the gray walls, moving from grid to grid. He can't stop half way between the guides. The player is pinned to the blank, because the blank is the size of the grid.

    I have tried a combination of platform, drag & drop, tile movement, physics. All of them will do something, but combining them stops the needed behaviors. Solid works great, unless I add drag & drop (to keep the player on the Y). If I remove drag and drop the player only moves using the keyboard and if I add something else then the keyboard won't move the player. And solid rarely works at all.

    What am I doing wrong? There must be a simple way, using the behaviors, to get the player to move from 1 grid to another without going beyond the walls.

    Any hints?

    drive.google.com/file/d/1RVZARDPRWX7__G4Y4ZWAxkg7qCxR8sa1/view

  • you could do something like

    set player x to round(mouse.X / cell_width) * cell_width

    this would make the player move to the mouse, but snap it to the grid at the same time

  • ,

    Thank you for your suggestion, it gave me an idea. I set the X in the tile movement to 300 and Y to 0. Then removed all the other behaviors except tile movement - and it worked!

    The problem is, it still won't work with the mouse, only works with the keyboard.

    I can't seem to use 'cell_width' from your formula, I'm told it's invalid. (There is the possibility I'm entering it incorrectly) (I replaced cell_width with 85, the cell width)

    I'll keep plugging away.

    Thanks for the help.

  • ,

    Thank you for your suggestion, it gave me an idea. I set the X in the tile movement to 300 and Y to 0. Then removed all the other behaviors except tile movement - and it worked!

    The problem is, it still won't work with the mouse, only works with the keyboard.

    I can't seem to use 'cell_width' from your formula, I'm told it's invalid. (There is the possibility I'm entering it incorrectly) (I replaced cell_width with 85, the cell width)

    I'll keep plugging away.

    Thanks for the help.

    when you use mouse you should temporarily disable the tile movement behavior so it doesn't get in the way

    Yeah I meant for 'cell_width' to be a variable that you define :)

  • ,

    The problem is I need the tile movement to work when using drag and drop. I think disabling it would disable the problem I'm trying to solve.

    I'll try move to and tween, hopefully I'll get some love there.

    Thanks again.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • ,

    The problem is I need the tile movement to work when using drag and drop. I think disabling it would disable the problem I'm trying to solve.

    I'll try move to and tween, hopefully I'll get some love there.

    Thanks again.

    I'm not sure what the problem is. I think I accomplished what you wanted by simply snapping the mouse movement and disabling tile movement when dragging

    gofile.io/d/1DsMk3

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)