TRMG's Forum Posts

  • It doesn't get too much simpler. With Alextro's you can still drag through the walls, and it may not work well for long shapes. If you tried the code I posted it would stop at walls but would snag on them and not slide.

    For sliding here are two different ways. The first moves horizontally then vertically a step at a time. Sliding works very well for unrotated walls.

    https://www.dropbox.com/s/s70h5bf670edb ... .capx?dl=0

    The second just pastes in the wall slide events I've used elsewhere with some other capx's. It's surprisingly modular I must say. Anyways, it requires putting an imagepoint at the corners of the walls, but the end result is smooth wall sliding.

    https://www.dropbox.com/s/251tpcwb6mg0u ... .capx?dl=0

    Alight then, thanks!

  • ... haha i hate drag and drop too!!

    too many variables to make it work perfect.

    I can help to u if u upload a simple capx.

    Cheers.

    Use my method: how-do-i-set-drag-bounds-for-a-sprite_t122964?&start=10&hilit=drag

    This is a start:

    Global number x0

    Global number y0

    Global number x1

    Global number y1

    Start of layout

    --- set x0 to Sprite.x

    --- set y0 to Sprite.y

    Every tick

    --- set x1 to Sprite.x

    --- set y1 to Sprite.y

    --- Sprite: set position to (x0,y0)

    --- Sprite: set angle towards (x1, y1)

    Repeat distance(x0,y0, x1,y1) times

    --- Sprite: move forward 1 pixel

    ------ Sprite: is overlapping wall

    --------- stop loop

    --------- Sprite: move forward -1 pixels

    Every tick

    --- set x0 to sprite.x

    --- set y0 to Sprite.y

    That will stop the Sprite at walls when being dragged. Having it slide against the walls is more deluxe. There are a few examples around the forum. Not exactly simple but there may be other ways.

    Oh wow, didn't expect it to be this difficult... Is there a simpler way of doing it?

    Here's a capx: https://www.dropbox.com/s/6cvo3w40rdv9u ... .capx?dl=0

  • bump...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm sure adding Solid behaviour to both, walls and the ball, will solve your problem

    I added it, but the ball still goes trough the walls...

  • Hey, I'm trying to make a game where you need to drag a ball trough a maze.

    I'm using drag and drop to drag the ball, but I don't know how to stop it from going trough the walls...

    I first made it drop the ball on collision with the wall, but then you can just pick it back up and go trough the wall;

    Then I added the physics behaviour to both the ball and the walls and made the walls immovable so that when I drop the ball, it would get "flinged" out of the wall.

    But this isn't quite what I want... I'd like to keep dragging the ball even if the mouse is over a wall, but the ball to stop at the border with the wall and to move only sideways with the mouse...

    So, is there a way to get this to work?

    Thanks!

  • Hey, so basically, I want to move this object with the mouse on a grid in-game.

    Hopefully I have explained it well enough, if not, here's a picture that may help:

  • number%10 will get the last digit.

    And this formula should append the correct suffix to the number.

    value & ((value % 100) - (value % 10) = 10 ? "th" : value % 10 = 1 ? "st" : value % 10 = 2 ? "nd" : value % 10 = 3 ? "rd" : "th")[/code:8adh9vq8]
    

    Thanks guys!

  • Hi, I'm trying to make a calendar inside my game which would show a number and after it have it say "st", "nd", "rd" and "th" based on the day.

    So I thought that I could check to see what the last digit of the number is and then set the text to the whole number and then "st" or "nd" etc...

    I would need to change this for 11,12 and 13 since these end with "th", but since they are only 3, it won't be such a hassle.

    Are there any better ways of doing this?

    If not, then how do I get the last digit from a number?

    Thanks!

  • > Maybe instead of:

    > Browser | Go to URL

    > try:

    > Browser | Open URL in new window.

    >

    no, This is not

    Try to use engin20020 's method in a new project.

    If it works in the new project and not in your current one, then it's a fault within your code...

  • >

    > > You can do this with rexrainbow "GridMove" behavior. The code for this is very simple.

    > >

    > > Just add the "Board" & "SquareTX" plugin to your project.

    > > Add a new sprite "tile" and give it the behavior "Chess".

    > > Add the "GridMove" behavior to your player.

    > >

    > > On start -> Fill board with "tile" //tile is a sprite object for your ground.

    > >

    > > On touched object "tile" -> Player move to "tile.Chess.LX, tile.Chess.LY"

    > >

    > > All plugins and behaviors can be found here.

    > > http://c2rexplugins.weebly.com/

    > >

    > > Regards

    > > Andy

    > >

    > Hey Andy, I have done what you said (without the fill board thing), but it doesn't work...

    > Here's the .capx: https://www.dropbox.com/s/upab2qxj9njp3 ... .capx?dl=0

    >

    The board is the important part <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";)" title="Wink">

    I updated your capx example, please find it here.

    https://www.dropbox.com/s/wbm43691jwsaa ... .capx?dl=1

    Regards

    Andy

    I see =D

    Thank you

  • You can do this with rexrainbow "GridMove" behavior. The code for this is very simple.

    Just add the "Board" & "SquareTX" plugin to your project.

    Add a new sprite "tile" and give it the behavior "Chess".

    Add the "GridMove" behavior to your player.

    On start -> Fill board with "tile" //tile is a sprite object for your ground.

    On touched object "tile" -> Player move to "tile.Chess.LX, tile.Chess.LY"

    All plugins and behaviors can be found here.

    http://c2rexplugins.weebly.com/

    Regards

    Andy

    Hey Andy, I have done what you said (without the fill board thing), but it doesn't work...

    Here's the .capx: https://www.dropbox.com/s/upab2qxj9njp3 ... .capx?dl=0

  • 99Instances2Go

    Thank you very much for the indepth reply and for the .capx!

    [...]I gonna try to steer you to use the Official.[...]

    Why? Is the official one faster?

  • I see. Maybe you can try adding an additional event with Pathfinding - On Arrived to snap to your target.

    Another approach I would try if you need clear steps on your grid during the movement is to set up your own custom movement. Use the pathfinding node expressions to pull out the path the behavior found (maybe into an array), and translate the coordinates to snap to your own grid size (by rounding). Then with the custom movement behavior, set the desired step size (to your grid) and move towards each waypoint/node in succession.

    The first method looks kinda janky since it's moving smooth most of the way and then it snaps into place.

    Can you explain how to make the second option a bit more? I don't really know how to use these behaviours...

  • Have you tried the built-in pathfinding behavior?

    I have, but it isn't very grid accurate... (It doesn't stop moving at the right time, meaning it ends being either in front of, or behind the grid square...)

    (The settings I used: Cell size = Grid size, Cell border = 0 or -1 (Didn't seem to make a difference), Rotate object and Diagonals both off)

    Explain what 'the moving' is supposed to do ?

    To move a sprite from a square of the grid to the one the player clicks on.

    Hope that cleared it up...