If layout exists

Forum Home Forum Home > Construct 2 General > How do I....?
 Post Reply Post Reply Page  12>
Author
3,443 Rep
Post Options Post Options   Quote Zephlon Quote  Post ReplyReply Direct Link To This Post Topic: If layout exists
    Posted: 20 Mar 2012 at 3:35am
Is there a way to check if a layout with a given name exists?
Back to Top
3,490 Rep
Post Options Post Options   Quote Kapandro Quote  Post ReplyReply Direct Link To This Post Posted: 20 Mar 2012 at 3:44am
Yes, go to the projects bar on your right, and look in the layouts folder. If this makes no sense, go to the VIEW tab on the top of construct2 and check off "Project Bar"
Back to Top
3,403 Rep
Post Options Post Options   Quote Fimbul Quote  Post ReplyReply Direct Link To This Post Posted: 20 Mar 2012 at 3:48am
I think he means via events. I never needed such a function so I can't say, but my guess is no, you can't do that.
If that is the case, it should be trivial for @Ashley to implement it. If he's too busy or you need this urgently, it's pretty easy to grab the SDK and do it yourself - heck, I'd bet someone on the chat would be willing to do it for you!

Edited by Fimbul - 20 Mar 2012 at 3:50am
Back to Top
3,443 Rep
Post Options Post Options   Quote Zephlon Quote  Post ReplyReply Direct Link To This Post Posted: 20 Mar 2012 at 5:22am
Originally posted by Fimbul Fimbul wrote:

I think he means via events.

Oh sorry, I forgot to mention that.

Originally posted by StephenC StephenC wrote:

Yes, go to the projects bar on your right, and look in the layouts folder. If this makes no sense, go to the VIEW tab on the top of construct2 and check off "Project Bar"

I'm not an idiot, I know how to look in the list of layouts, but I don't know how to teach the game to do that.
Back to Top

Moderator
28,456 Rep
Post Options Post Options   Quote Kyatric Quote  Post ReplyReply Direct Link To This Post Posted: 20 Mar 2012 at 8:47am
You can't create layouts at runtime, so existing layouts are those you made/named yourself.

To check the current layout's name make a system "compare two values" event, and check for the system expression "LayoutName" and "The_name_you_want".



Edited by Kyatric - 20 Mar 2012 at 8:48am
Back to Top
3,403 Rep
Post Options Post Options   Quote Fimbul Quote  Post ReplyReply Direct Link To This Post Posted: 20 Mar 2012 at 3:11pm
@Kyatric, doesn't LayoutName return the name for the current layout only?
I don't think there's a way to iterate over all available layout names, the only workaround (which is a bit of a hack) is to create an array, fill it with layout names, and iterate over that instead.
Back to Top

Moderator
28,456 Rep
Post Options Post Options   Quote Kyatric Quote  Post ReplyReply Direct Link To This Post Posted: 20 Mar 2012 at 10:33pm
If you need to iterate, just use a variable in "The_name_you_want".

Something like:

Loop VariableValue from 0 to 10
.. Layoutname = "Level" & VariableValue

It will make sure that the current layout name is "Level0" and then "Level1", etc...
But once again, as a creator, you know how many and what the name of the layouts are, anyway, since you made them at edittime.

I really don't see the problem here.
Back to Top
3,443 Rep
Post Options Post Options   Quote Zephlon Quote  Post ReplyReply Direct Link To This Post Posted: 21 Mar 2012 at 12:07am
I was trying to find a way to have a level selection menu be automatically generated. Until this is possible, I'll use Kyatric's idea. Thanks.
Back to Top

Moderator
28,456 Rep
Post Options Post Options   Quote Kyatric Quote  Post ReplyReply Direct Link To This Post Posted: 21 Mar 2012 at 12:39am
@Zephlon: do you mean something like this ?
Back to Top
3,443 Rep
Post Options Post Options   Quote Zephlon Quote  Post ReplyReply Direct Link To This Post Posted: 21 Mar 2012 at 3:02am
Kind of. I have a level selection menu made:
http://dl.dropbox.com/u/52788071/Poggle/index.html

I was hoping to have the game check if each level exists, and mark the ones that don't as "Coming Soon". I guess I'll just leave it as it is.

But one thing I can't figure out is how to have multiple pages of levels, and a sliding animation to switch between them. Angry Birds's level select menu has this. I tried having the level buttons in the own layer, and setting the parallax on the other layers to "0,0", but that caused those layers to appear too far up and left.
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down