Global Variable Passing Problem [SOLVED] [C2]

0 favourites
  • 5 posts
From the Asset Store
Globals 2.0
$3.60 USD
10% off
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Hey, guys.

    I'm assembling the final pieces of my video game for Android release, then Xbox, PC.

    I've encountered a weird problem almost at the end and no idea how to solve it.

    I'm using this function just to move a sprite when the layout loads based on a global Score variable from another layout.

    lerp(Player_Ship1_c.X,gotoX_ccy,dt*dtmove_ccy)

    Here's the problem.

    1) The layout works just fine when changing the variable when loaded either as a separate layout, or as the starting layout in the merged capx with lots of layouts.

    2) the global variable Score seems to pass to the target layout, tested with text object.

    3) The move condition works too based on 1).

    The problem is when testing the first condition, based on the first score, AS PART OF THE MERGED CAPX, the sprite goes to 0,0 as opposed to the target position and I can't figure out why as the variable seems to pass.

    I've encountered one minor corruption before which I fixed, but here nothing seems to work because the capx works individually, just not as a part of the merged whole. I deleted the layouts and event sheets several times before reintegration.

    Any help would be greatly appreciated as otherwise I will have to cut this cool portion of the game.

    ---

    I've even made a new variable in the target layout and set it to Score. No dice.

    Anyone encounter this before and find a solution?

  • Looks like it is using Score=0, so you're running the initial set position function before you set Score?

  • thanks for chiming in plinkie

    seems to be a corrupt layout cause all others pas the variable just fine

    i haven't gotten to it yet, will probably have to recode from scratch, it's not that big, at least i hope that's what it is

    on another note, any idea how to switch music tracks in game based on trigger?

    tried touching a control/sprite w subevents

    --is playin track a - stop track a play track b

    but that doesnt work at all

    I know how to push arrays now too, but cant figure out how to play music tracks based on array x. there seems to be nowhere to put the "at"

    will try it by activating groups now

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That logic seems sound to me. Probably just logic confusion somewhere. Not sure what you mean about the arrays though!

  • That was a good call.

    It was a programming issue.

    I had <1,000,000 as first condition.

    What fixed it was making it comprehensive.

    0

    <=1,000,000

    In my mind they are equivalent.

    No idea why that would make a difference.

    Only thing I can think of is comprehensiveness as Construct 2 seems to hang up occasionally unless you cover every conceivable possibility.

    Not sure if this is unique to Construct 2 or just a basic programming precept or something having to do with this particular expression.

    Anyway, it's solved and the game is done.

    https://play.google.com/store/apps/deta ... es.DarkSun

    Many thanks!!

    (I still gotta ask you some questions about some of the code you sent me. It's great. I just don't understand if this is unique to Construct 2 of just a basic programming concept.)

    But I'll have to catch my breath <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

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