How get global var. from first to second layout

0 favourites
  • 8 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • 1. My player gets double jump on layer 1 and global variable it's =1

    What to do to still have this variable on global var in next layer ?

    2. Also whn I take double jump in first layer, go to layer 2 and back to layer 1 - double jump is there again. System should remember that i take this sprite.


  • 1. A global variable means it's global to the whole project.

    A global variable set in event sheet 1 will be available in a later executed event sheet 2.

    2. If you load a layout, it will load with every default elements you've setted it for. Meaning if you have a "Double jump" sprite that stands in the layout, you might very well destroy it in the first execution of the layout. If you load again the layout, the sprite will be spawned again.

    You have to take care of such "disapearing" objects in the event "Start of layout" (with the help of a global variable for example).

  • ok, about point 2:

    So if I back to layout 1 by tuching door - I should add event - delete double jump ?

    But soetimes player couldn't find double jump in layer 1, so haven't got it yet. So I can't delete it.

  • That's where comes the use of a global variable.

    Your global variable keeps the state of your PowerUp (the double jump, I guess it is a power up).

    Check this capx.

  • eh doesn't work for me.

    event sheet 1

    global var - doublejump = 0

    When player found DoubleJump sprite = Add 1 to DoubleJump (global)

    DoubleJump is visible - when System set DoubleJump = 1

    And Layer 2 doesn't remember this. I can't double jump in layer 2 and when I back DoubleJump sprite is still there (but I taken it before)

  • I stil checking your capx, but it's works for you if you don't need to jump. Maybe I got this jump but it doesn't work. I can't jump.

    I checked global (right corner) and now when I back to layout 1 - sprite is invisible.(so only that work)

    It looks like this.

    <img src="" border="0" />

    <img src="" border="0" />

  • Using the same variable name for global and private instances is the best way to lose yourself.

    You are overcomplicating things a great deal.

    Check this other capx.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I got it

    Problem was that I added this:

    Sprite2 is visible - Set doubleJump to 0

    thanks fo capx

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