How do I Fix All These Mindboggling Fails?

Just started using Construct 2? Post your questions here

Post » Mon Jan 30, 2017 3:30 pm

I'm working on moving my sprite between layouts, based on this simple but brilliant .capx file:
https://www.dropbox.com/s/5vatkqilropb9ui/LayoutChangePosition.capx?dl=0

I have copied the logic into my project, but I have a few problems (Note: I am not a programmer; unless the solution is spelled out for me, I have no idea how to fix it).

1) The simple .capx file above moves the sprite between 2 layouts, A <--> B.
Right now, I have 3 layouts (and will have more). I need to know how to move the sprite A <--> B <--> C.
I tried tinkering with the logic based on the simple .capx file, but it didn't work.

2) My sprite is spawning all over the place. It's supposed to spawn at the position of the portals.
On the first layout, it spawns where I have placed the sprite manually.
On the second layout, it spawns in the margins somewhere.
On the third layout, it is nowhere to be found.

3) And lastly, I have defined a custom cursor, but it doesn't "appear" until the second layout.

Can anyone explain, step by step, what I should do to fix these problems?
Here is my file: https://www.dropbox.com/s/9eprtnqn26l0aku/LayoutChangeError.capx?dl=0

Thank you for reading this!
B
8
S
2
G
1
Posts: 89
Reputation: 1,230

Post » Mon Jan 30, 2017 5:30 pm

1) I think you've made this too complicated. All you need is two events, one for left and one for right. When Stapleton is overlapping the sprite on the left go to previous layout, when Stapleton is overlapping the sprite on the right go to next layout.

2) You set Stapleton position but you don't actually create the object. When you go to a new layout you need to create Stapleton unless it's in the layout view by default.

3) Again you don't have a cursor anywhere on the layout so it can't load it. If you look at Final Hall you'll notice that the cursor is off screen.

Some tips :
Previous/next layout works by using the order in which the layouts appear in the Project bar list. So next will always go to the next room if you list them in the correct order you want in the game.

When you go to a new layout it unloads everything from the previous layout in memory, and loads everything on the current layout. This is why it can't see your objects. You need to have them in the layout already or you can spawn the player on start of layout.
B
47
S
17
G
82
Posts: 2,230
Reputation: 48,607

Post » Mon Jan 30, 2017 10:43 pm

Hi Plinkie!
Okay, I did what you said as far as simplifying the layout changes. Please check out this simple example:

https://www.dropbox.com/s/nd4gmalux6qqilw/3ScreenLayoutChange.capx?dl=0

It works great, save for 2 things:

- How do I have only 1 Player spawn on the screen at a time? Layout A spawns 2 Player sprites, even though I moved one into the margins. Like you say, it has to be on the screen somewhere or the system won't know what I'm talking about.

- I'm trying to make it look like the Player is moving from room to room... therefore, when it exits on the right side, I'd like to have it appear on the left side of the next layout (and vice-versa), ideally at a similar X and Y position as the previous layout. That way, when the Player exits Screen A from the bottom-corner right side, he appears on Screen B in the bottom-corner left side. Right now, it's just being spawned in a meaningless spot.

I know I'm asking a lot, but you have to believe me, I am not intuitive to this kind of logic. Can you please, please with sugar on top tinker with my simple .capx file (https://www.dropbox.com/s/nd4gmalux6qqilw/3ScreenLayoutChange.capx?dl=0) and reply with a working version?
B
8
S
2
G
1
Posts: 89
Reputation: 1,230

Post » Mon Jan 30, 2017 11:41 pm

Here you go: https://www.dropbox.com/s/004nkes7fv86y ... .capx?dl=0

I set up an ID so if you are in starting layout, ID is 0, layout B, ID is 1, layout C, ID is 2 etc. When you enter a layout it checks your ID, which will be the ID from the layout you just left from. So if you exit to the right at the start into the second layout, your ID is 0. It checks this and spawns you on the left if it is 0. If you enter the same layout from the right hand side (layout C) your ID will be 2 from that previous room. It just does a simple check, 0 or 2 and spawns in correct place. After the checks are done, it then sets your ID to the current ID of the room. When you then go into the next layout C it will check if your ID is 1 or 3, 1 being from layout B and 3 being from a future layout D.
B
47
S
17
G
82
Posts: 2,230
Reputation: 48,607

Post » Tue Jan 31, 2017 8:23 am

Here is an even "simpler" cap based on what you are asking.
Comments explain what is going on.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
294
S
117
G
96
Posts: 7,312
Reputation: 71,092

Post » Tue Jan 31, 2017 11:46 am

You guys...

THIS IS EXACTLY WHAT I NEEDED.

THANK YOU SO MUCH!!!!!
B
8
S
2
G
1
Posts: 89
Reputation: 1,230


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests