[Solved!] Problem with Teleporting

Get help using Construct 2

Post » Thu Apr 04, 2013 1:30 am

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..


Crazeh2013-04-04 04:58:29
-- Because a pig told me to be nice.
B
11
S
2
G
1
Posts: 29
Reputation: 1,327

Post » Thu Apr 04, 2013 1:41 am

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: https://www.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.rosareven2013-04-04 01:51:33
B
19
S
6
G
1
Posts: 116
Reputation: 2,730

Post » Thu Apr 04, 2013 1:57 am

https://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 ^_^Crazeh2013-04-04 02:02:37
-- Because a pig told me to be nice.
B
11
S
2
G
1
Posts: 29
Reputation: 1,327

Post » Thu Apr 04, 2013 3:36 am

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.
B
19
S
6
G
1
Posts: 116
Reputation: 2,730

Post » Thu Apr 04, 2013 3:51 am

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 :)
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Thu Apr 04, 2013 3:53 am

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.
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Thu Apr 04, 2013 4:01 am

Thank you! I will surf around a bit and see if I can learn how to do what you just suggested! :)
-- Because a pig told me to be nice.
B
11
S
2
G
1
Posts: 29
Reputation: 1,327

Post » Thu Apr 04, 2013 4:17 am

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! ^_^
-- Because a pig told me to be nice.
B
11
S
2
G
1
Posts: 29
Reputation: 1,327

Post » Thu Apr 04, 2013 4:56 am

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 <3Crazeh2013-04-04 04:57:38
-- Because a pig told me to be nice.
B
11
S
2
G
1
Posts: 29
Reputation: 1,327

Post » Thu Apr 04, 2013 4:44 pm

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.
B
19
S
6
G
1
Posts: 116
Reputation: 2,730

Next

Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], Rezzon71, tarek2 and 22 guests