[go to layout] causing application to close

This forum is currently in read-only mode.
  • so I have four buttons on the second layout of my project set to all add a certain value to a variable, and then go to a different layout. The problem is that when I press any of these my application closes out rather than go to the layout.

    docs.google.com/file/d/0B0gf0yi2MHX3MFJWX1ZaYWVpclU/edit

  • Ah since you're referencing them by name instead of their number you should put " marks around them, eg: "c1". Otherwise you can reference their layout number exactly (c1 would be layout 3 I think, unless it's 0-based then it would be 2).

    Going by name lets you do things like: Go to layout -> "Level" & (global('LevelNum') + 1)

    Edit, as a further example you can also bring randomness into it: Go to layout -> "Level" & clamp(random(3) + 5, 5, 8)

    This would go to a level between Level5 and Level8

    Hope that helps! <img src="smileys/smiley1.gif" border="0" align="middle" />

    Double Edit: Oops, did the math in my head wrong, this would only spit out Level5 to Level7, thanks Tulamide! <img src="smileys/smiley9.gif" border="0" align="middle" />

  • thankyou, this helps alot!

  • Anytime! <img src="smileys/smiley1.gif" border="0" align="middle" />

  • I have similar problem. I shared my game world into some sections to increase performence. In C2 i can see all of my lauouts, and by going to project folder, i see them in layouts folder (nice xml files). But where they are in html/exported mode?

    I noticed, there are some references to layouts look in c2runtime.js, but still I'm not sure - is that the place where all informations about layouts are stored ? If so, what is the purpose of two xml's in my cocoon-export folder ? Is it C2 garbage, or something ?

  • stachir ah this is for Construct Classic. Best place to ask for C2 is in this forum: https://www.scirra.com/forum/how-do-i_forum45.html

  • Sooo you say, I should first choose right category, and then write some stuff about my invalid problems ?

    ...

    holy mackerel ;/

    ok, sorry for inattention ;]

  • Heh no problem stachir <img src="smileys/smiley1.gif" border="0" align="middle" />

  • I know I should stay out of it, but since it is important and I am kind of a nitpicker who sometimes cares for examples being correct:

    Edit, as a further example you can also bring randomness into it: Go to layout -> "Level" & clamp(random(3) + 5, 5, 8)

    This would go to a level between Level5 and Level8<img src="smileys/smiley1.gif" border="0" align="middle" />No, it wouldn't. It would go to a level between "Level5" and "Level7". Also, clamp() isn't neccessary. The number range is already clamped through the use of random()

    random(3) spits out one integer of 0, 1 or 2. In general, random(i) => [0, i-1]

    random(3.0) on the other hand spits out any float >0.0 and <3.0 (e.g. 0.000001, 1.27 or 2.99999)

    I apologize for being meticulous, but it makes a difference. <img src="smileys/smiley1.gif" border="0" align="middle" />

  • tulamide, ah I found random doesn't spit out nice integers for me like I try to force it into, although the clamp wouldn't solve that either.

    And surprised to see random(3) is between 0 and 2, thanks for sharing <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • tulamide, ah I found random doesn't spit out nice integers for me like I try to force it into, although the clamp wouldn't solve that either.@Jayjay: I see. Maybe this could help.

    Internally a random function calculates a float that is always greater than 0 (zero) and lesser than the number you hand over. If CC detects a number without fraction part, it returns the calculated float without fraction part, too. That's why the range is [0, i-1]

    Throughout CC there's the problem of slight inconsistencies with very small or very high fractional numbers. That's due to the single precision floats CC is based on and can't be avoided. For example, you might experience some number like 1.234e-9 (=0.000000001234) where you expected a 0 (zero).

    If you want to have more freedom over the numbers generated by random(), you could use floats instead of integers and do the conversion yourself.

    floor(random(3.0)) => integer in the range [0, 2]

    round(random(3.0)) => integer in the range [0, 3]

    ceil(random(3.0)) => integer in the range [1, 3]

    pseudo code

    on function "myrandom"

    set return value to round(random(param(2) - param(1)) + param(1)

    set text to function.myrandom(3, 8) => integer in the range [3, 8]

    set text to function.myrandom(2.5, 4.75) => float with integer steps in the range [2.5, 4.5] (2.5, 3.5, 4.5)

    Hope it helps :)

  • tulamide Awesome, thanks for explaining that for me <img src="smileys/smiley4.gif" border="0" align="middle" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)