Layout Question

For questions about using Classic.

Post » Tue Dec 09, 2008 1:41 am

How could I do a thing where like I go to the left and it loads a new layout but you spawn on the right in the right place? My game I'm making requires this, and I don't know how to pull it off. Like the MM games except each screen shift is a layout and it just instantly changes. I need halp.
B
2
G
4
Posts: 16
Reputation: 1,082

Post » Tue Dec 09, 2008 3:09 am

Something like this(note: not actually code, but easy to understand):

+ = conditions
- = actions

FIRST LAYOUT:
+ Character reaches left of screen
- Set global variable 'yposition' to character.Y
- Set global variable 'side' to "left"

SECOND LAYOUT:
+ On Start of Layout
+ If global variable 'side' is equal to "left"
- Set character.X to 640
- Set character.Y to global('yposition')
+ If global variable 'side' is equal to "right"
- Set character.X to 0
- Set character.Y to global('yposition')

If you want, I could probably rig up an example file pretty quickly. Hope that helps. :)
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Tue Dec 09, 2008 3:14 am

I was thinking he should just divide his large level into smaller parts by repositioning the camera. It's more efficient than creating multiple layouts.
B
2
S
2
G
4
Posts: 136
Reputation: 1,722

Post » Tue Dec 09, 2008 4:01 am

[quote="Barri167":2va531po]I was thinking he should just divide his large level into smaller parts by repositioning the camera. It's more efficient than creating multiple layouts.[/quote:2va531po]

I actually created something like that for the MM2 remake I had been working on. I just had two different screen-sized bricks which I placed in a grid, alternating between the two. If you collided with one that was different than the one you were already in, it would scroll. Unfortunately, that code is pretty cluttered and hard to understand. I need to figure up a better way of doing it.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Tue Dec 09, 2008 4:03 am

We should ask DeadEye. [u:1cfpp999]This Cursed Rock[/u:1cfpp999] clearly has what we're looking for.
B
2
S
2
G
4
Posts: 136
Reputation: 1,722

Post » Tue Dec 09, 2008 4:17 am

Er, that depends, I guess. Do you mean that at the end of the whole level you want to change screens automatically and start your character off in the right place, or do you mean you want the screen to scroll one screen at a time on a grid like I did in my game?

If you want the first one you just need to set your character's x,y in the Start of Layout.

If you want the second one, you don't need a layout for each screen. Just make one large layout like normal. Here's how I did the scrolling in TCR:

[code:32brt6iw]
+Always
->System: Scroll X to floor(playerSprite.X/640)*640+320
->System: Scroll Y to floor(playerSprite.Y/480)*480+240
[/code:32brt6iw]

This splits the level up into a 640*480 grid, basically. You have to make sure your layout size is a multiple of your display size in order for it to work right*. And, naturally, if your display size is different than 640*480 the numbers would be different.

*(For example, my whole level is six screens by six screens, so the layout size is 640*6 = 3840 pixels wide and 480*6 = 2880 pixels tall.)
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Dec 09, 2008 4:22 am

Screw you, deadeye, I was about to post an example I had whipped up. :P Yours uses one less event.

Ah, well. Here it is anyways if anbody is interested: Grid Scrolling Example
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Tue Dec 09, 2008 4:27 am

Hehe well, that works too :)
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Dec 09, 2008 10:10 pm

I only need this because it's an open world game and Construct lags HORRIFICALLY when I try and do anything in the layout, so I need different layouts for different towns/locations so it isn't laggy and I can actually complete it.(Construct lags, not the game, the game runs fine)
B
2
G
4
Posts: 16
Reputation: 1,082

Post » Tue Dec 09, 2008 10:32 pm

How big is it?
And if your not doing so already, why don't you make the buildings smaller and when you go inside you would go too a new layout and you would be in the proper building?
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest