Player Spawning at Different Points

Get help using Construct 2

Post » Tue Jul 07, 2015 4:09 pm

mindragon73 wrote:Hi!

I´m actually trying to do the same thing, and what I´ve done and which seems to work ok so far (even if I´m sure there is a smarter way of doing it), is something like this (pretty close to what you have done)

I have two global variables: DestinationX and DestinationY

I have an "Exit Sprite" with three instance variables: nextX, nextY and NextLayout.
I place the sprite where I want an exit to be.
Then I set the variables in that sprite instance to where I want the player to "teleport" to.

Then I have an event saying something like (if I recall correctly):

Player -On collision with ExitSprite -> set DestinationX to ExitSprite.NextX
-> set DestinationY to ExitSprite.NextY
-> go to Layout(ExitSprite.NextLayout)

And on each layout I have an event saying:
On start of layout->create player at DestinationX, DestinationY

Also, I noticed that I had to have the player sprites (I have a hitbox, a "movebox" and the actual animated sprite) on a separate layout not used in the game to avoid duplicate players to spawn in the layouts.

So you're recording the X and Y coordinates of the destination and just sending the sprite there instead of onto an object? I'll give that a shot when I get home, thanks. I have had the duplicate players issue, so I'll move them all do a separate layer also. Thank you!
B
11
S
2
G
1
Posts: 79
Reputation: 842

Post » Tue Jul 07, 2015 4:57 pm

I should mention that I set the x and y to be slightly on the side of next level's exit object, to avoid the infinite teleporting. But I suppose it's actually more versatile to have a destination object ( like you do) instead of setting the x and y. That way if you change the level you don't have change the coordinates in a lot of places, but rather just move the object.
B
28
S
7
G
4
Posts: 20
Reputation: 3,819

Post » Tue Jul 07, 2015 7:25 pm

mindragon73 wrote:I should mention that I set the x and y to be slightly on the side of next level's exit object, to avoid the infinite teleporting. But I suppose it's actually more versatile to have a destination object ( like you do) instead of setting the x and y. That way if you change the level you don't have change the coordinates in a lot of places, but rather just move the object.

Yeah, that versatility and making level-building easy was what I was going for, but if I can't get that to work, at least your method works!

Although, you could probably set something up so that when the layout loads, or on start of layout, each exit variable is set to whatever the sprite's X and Y coordinates are, so it is automated like my method but thorough enough to work like your method...

EDIT: Ignore the preceding paragraph because I'm an idiot.

Also, I got it to work using mindragon73's method, but adding a variable called ExitAvailable that is made false on start of layout, and then made true once the player is no longer overlapping an exit sprite. Thanks everybody!
B
11
S
2
G
1
Posts: 79
Reputation: 842

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests