SOLVED - How Do I Combine TileMovement and Wrap so the Player Stays on the Screen?

0 favourites
  • 3 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • I have an Object named "Player" with two behaviors TileMovement and Wrap.

    Moving "Player" around the screen works great. But, when he goes off one side of the screen, he has to be fully off before he will appear on the other side of the screen.

    So, it takes two arrow pushes to move him from one side of the screen to the other and I would like it to take one (as he goes off one side he should be appearing on the other).

    I realize I could write code to instantly move him from one side to the other, but then I would lose the animation that is happening as he moves from tile to tile (sliding off the screen and then onto the screen).

    Does anyone have an example or suggestion on how best to do what I would like to do?

    Update: Currently my tile size is 120 x 120 and my player object is 120 x 120. I just changed the player size to 119 x 119 and that will mostly solve my problem - it goes from one side to the other directly - it just doesn't animate it happening at the exact same time. If someone has a suggestion on how to do that, I would love to hear it.

  • If you want to keep the animation when the player is moving to the other side of the screen, you need to have a copy of your player sprite that can handle that animation while the sprite is at the other side of the screen.

    Basically, as soon as the player leaves the layout, you teleport it on the other side of the screen, and you place your player copy where the player previously was. Then you animate the player copy.

    I made an example project to show you how to do this. Note that i don't use the wrap behaviour for the player (implementin it is just 4 events). The animation itself is done with the tween behaviour. If you go in debug mode, you'll see that the player is inside the screen at all times.

    Here's the project: dropbox.com/scl/fi/d4ab0aolo0vkmm2pueway/Tile-movement-warp.c3p

    I suggest not to have a player of size different from the cell size. That could cause bugs in the future that will be hard to find.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This community is so amazing!

    Thank you so much for the answer and then taking the extra time to write and share the sample code with me.

    It's the perfect solution to my problem.

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