How do I correctly use touch/mouse movements for main Sprite

0 favourites
  • 8 posts
From the Asset Store
Create your game with this complete pack of images and animations!
  • I am not sure how to explain it, but pretty much the way I am controlling the sprite is with mouse or by touch(THIS IS NOT THE PROBLEM) (I know how to implement them both). The PROBLEM: When I use these methods the main sprite goes through the boundaries.

    For example, I am making a maze game. I want to control my main sprite with mouse or through touch. When I use these methods the sprite goes through my boundary blocks that make up the maze itself. My question is how do I make the main character sprite either bounce off or not go through the blocks that make up my maze, while using touch/mouse features. To further give you detail, in a maze you don't go through it, you are supposed to find your way out by finding a path in the maze. If I can get this done, that would be detrimental to what I am building. Please if you know how to solve this it would be greatly appreciated!

  • Does your Player Sprite have any or all of these Behaviors:

    • Bound to Layout
    • Solid
    • 8-Direction

    Do your boundary blocks have the Solid attribute?

  • Yes, they both have 'solid' on. The main character, the guy that you control has 'bound to layout' so he doesn't go out or bounds outside of the whole level. That's the weird thing, I would expect since the boundary blocks that make up the trail for the maze are solid and the character is set to solid that the character wouldn't go through them, but somehow they still do. If you need anymore info, let me know. I've done the usual stuff that are needed, maybe there is a function that i am not aware about?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • umajoe a capx-file would be very useful...

  • Okay: Solid objects can totally overlap. What behaviors are you using to control the character?

    Or are you using, like, "on tap move character towards tap position"

  • Touch and Mouse enabled

    boundary blocks/character set to solid

    character- bound to layout, Scroll-to,

    Touch-Is in Touch- Sprite(Main Character)- Move- Angle:Self.X,Self.Y, Touch.X, Touch.Y) Distance:300 * dt

    This is what I have for the Event sheet, nothing more, just the movement code. I'm sorry I don't know how to put the capx file in here so I just wrote out the event sheet...

    I want to solely move the Main Character(sprite) in between the boundaries that make up the maze through touch or mouse movement. The way I have configured the movement through the code is more or less the way I want the movement to be(pretty smooth) I have a touch screen so I can test out the touch movements. It seems no matter what I try I still can't get the Main sprite to stop going through the boundary blocks. Tried setting him as a platformer but nothing.

    Let me know, thanks!

  • Well, for reference you upload the .capx file by saving as a .capx, then clicking the "Upload attachment" tab at the bottom of the reply box (needs full editor,) then select that .capx file. (as I have done below)

    I think if you're using a custom movement like that, your best best is to use the Physics behavior.

    Give both player and walls Physics. Set Walls to immovable and Prevent Rotation to yes. Set Player to Prevent Rotation.

    Very important, however, is to set World Gravity to 0 at the beginning of the layout, or else your player will always fall down.

  • Unnatural, I appreciate your consistent help. I think instead of what I am trying to do I am going to implement PacMan style controls from a tutorial that they have here. I'll give you a heads up when I am near completion! Thanks!

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