Global Variable Passing Problem [SOLVED] [C2]

Just started using Construct 2? Post your questions here

Post » Tue Aug 15, 2017 12:45 am

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?
Last edited by AmpedRobot on Sat Aug 19, 2017 4:13 pm, edited 2 times in total.
B
41
S
20
G
18
Posts: 274
Reputation: 13,055

Post » Tue Aug 15, 2017 2:45 pm

Looks like it is using Score=0, so you're running the initial set position function before you set Score?
B
47
S
18
G
84
Posts: 2,273
Reputation: 49,800

Post » Tue Aug 15, 2017 8:59 pm

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
B
41
S
20
G
18
Posts: 274
Reputation: 13,055

Post » Thu Aug 17, 2017 8:23 am

That logic seems sound to me. Probably just logic confusion somewhere. Not sure what you mean about the arrays though!
B
47
S
18
G
84
Posts: 2,273
Reputation: 49,800

Post » Sat Aug 19, 2017 4:11 pm

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 :)
B
41
S
20
G
18
Posts: 274
Reputation: 13,055


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests