[Solved!] Problem with Teleporting

0 favourites
  • 12 posts
  • When my 'global' player teleports from a box on one layout, she automatically ends up at the corresponding x-y area on the target layout. This looks rather odd.

    I would like to be able to f.ex have several houses on one layout (each house also being it's own layout), and when the player leaves the houses, it should end up on an invisible block outside the house it went in to.

    Is there any way I can f.ex tell the layer it arrives at, to check which layer it came from, and then place the player on an agreed on block?

    I realized I Could copy the target layer 50 times and have each "house" lead to it's own instance of the target layout, but this seems like a massive waste if it can be done simpler, and I could in that case not use a global player.

    Sorry if this is poorly explained.. I've only been playing around with construct for a little over a week..

  • Do you have the capx to show us? It would be easier to see what your current set up is that way.

    If you don't mind being able to see the interior of other houses in case they're close by, the outside world can be on the top layer and interiors being the bottom. Then it's just a matter of toggling the outside visibility as you walk in and out of the house. Most classic JRPGs are like that where you can see interior of other buildings when you aren't in those buildings.

    If you only want the player to see the interior they are in, the blend mode might be your savior: scirra.com/manual/146/effects

    Basically, have your outside layer and interior layer, then in your interior layer, cover your rooms in pure black blocks of sprites (assuming the background of nothingness is black). When you walk inside a house and touches that black sprite, you can change that black sprite's blend mode to Destination In and reveal only that room you walked into.

  • dl.dropbox.com/u/44684026/64.capx

    I'm feeling it might simplify things for me if I can use separate event sheets on the different rooms/houses, and areas.

    Please excuse the random mess in the set-up of things, was not planning on having visitors.

    And I've not spammed the forums enough to get to use an actual link ^_^

  • Transferring values between layouts is tricky. At the moment the easiest way to do that is only by global variables.

    You can make global variables of the x y coordinates where you want the character to arrive to on the island map. Assign those coordinates when the player leaves the house, and vice versa when the player enters the house.

  • Going off the top of my head, you could set up a list of coordinates, in an array for example, which say where the player 'lands' when she leaves the house. So when you go to the island screen, you'll have a 'On start of layout' event which checks where the player came from (I'd store that in a global variable, so when you leave a house, set a variable to the number of the house which was left), then you can check your array for the coordinates to place the player at.

    Or, you could have special tiles (like a sort of 'doorstep' tile) which are placed outside each house, which look the same (or you could make them look differently, like a different doormat for each) but have a certain value connected to them. Then when you leave the house, again set the global variable ('WhichHouseLeft' or something) to the house number, then you pick the tile which has the value, e.g DoorMatTiles > Number = WhichHouseLeft ... then place the player on that tile.

    I'm just winging it here but that might give you some ideas.

    Either way, you're probably going to need to use a global variable. Don't be afraid of them, they're really useful and easy to use and don't HAVE to be messy if you use them sparingly.

    Cute game by the way, stick with it :)

  • Oh and by the way, I wouldn't use a seperate event sheet for every house, unless you intend to have the action inside each house wildly different. That's just unncessary and will make a larger project and much more work for you. You can easily have a single event sheet to control the behaviour in all houses.

  • Thank you! I will surf around a bit and see if I can learn how to do what you just suggested! :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The wanting to have separate event sheets for each sprung out of the issues I had with the character responding to auto messages with the npc's, where they would both speak a word when she was overlapping it's sprite. But when she was set to respond to two different npc's, I ran in to some issues with her not shutting up when she leaves their area. and the "or" statement not working as I would prefer it did. ^_^

    Simply copying events seemed like an ok quick fix.

    Not gotten round to looking too deep in at it yet, will probably have to if I want her auto responding to more than one on a layout, just not had time since most time so far goes to drawing the damn graphics :P

    Had some thought to "click" talking tho, assuming the simplest way would be to have the chat bubbles auto destruct when walking away or clicking again, but I guess it involves these things you mention to have them give a different "reply" the second/third click etc, so i should get started on the stuff said so far :) So much stuff to learn! ^_^

  • It works it works it works!! I set a global number! When she overlaps the teleport sprite from the room, it sets the global number to 1, then the island checks the number, if the number is 1, her position is set to the 'invisible' sprite I want it to! Yay!!!

    Thank you <3 <3 <3 <3 <3

  • Good job!

    A list of arrays with different coordinates suggested by farflamex is great too, just for ease of remembering all of them - the array can remember them for you.

  • Oh, well I just set up a list of which numbers go where in comments above the global number thingy, works ok at this tiny world size ^_^ If I expand much more I'll def look in to the arrays :)

    Everything going sooo much smoother now thnx to you guys <3, even tho it's nowhere near actually being a game for some time still :D azylet.com/64 :)

  • You should definitely put all of your house logic into a single layout. If the houses are to do different things, you can use another global variable, 'Housenumber' or whatever. Then when you're going through your house layout (which now controls any house), if there's something specific to the house you're currently in, you'd just add..

    'Housenumber = 1' to the event, so that event only triggers when you're inside house 1, but not any other house.

    But then if you have stuff which can happen in ANY house, you can just leave the housrnumber variable out of the event and the event will trigger in all houses.

    You just need to wrap your head around the way these things work. Sometimes it seems easy to do the same piece of logic 10 times, but in reality there's always a way to do that piece of logic once and just add different conditions to ensure it only triggers when it should. Otherwise, things will quickly become very unwieldy.

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