Global Variable Not Working

Discussion and feedback on Construct 2

Post » Sun Feb 24, 2013 4:29 pm

I don't know if my analysis of this glitch is correct, but as far as I can tell this is the only explanation.

I have a game, where there is a global variable "Number of dead enemies." Every time an enemy is killed, it adds one to this variable. When this variable reaches 24, the game should display a win game screen. However, on random browsers, and at random times(I have tested this on Firefox, it happened the first time and didn't happen the second), the variable appears not to register, and the End Game layout does not appear.
The only other thing about this glitch I have noticed, is that at the start of the layout, instead of waiting 5 seconds like I programmed them, the enemy spawners create the enemies as soon as the layout loads. This always corresponds to the "No End Game" glitch.

Link to Capx: https://docs.google.com/file/d/0Bz5x2REX7ZtRMlRjUDVoLWVaZEU/edit?usp=sharing
Sorry its sort of messy.Aokpisz2013-02-24 16:32:34
B
3
Posts: 5
Reputation: 311

Post » Sun Feb 24, 2013 5:32 pm

You are not resetting your global on restart, so it keeps counting.
ImageImageImage
B
67
S
19
G
122
Posts: 3,207
Reputation: 73,401

Post » Tue Feb 26, 2013 4:53 pm

Thanks :D

Oh one other thing which I've been having trouble with, the "ScrollTo" behavior. The screen never scrolls to the object I assign the ScrollTo behavior to. I've tried manually having the screen(Every Tick --> Scroll To PlayerBox) scroll, but it doesn't do anything. It just has the window in the upper left corner of the layout, and the window never moves.

EDIT: (And yes, I know the layout and the window are the same size in the capx I posted, but if I shrink the window, it doesn't move with ScrollTo.Aokpisz2013-02-26 17:00:28
B
3
Posts: 5
Reputation: 311

Post » Tue Jul 23, 2013 6:29 pm

I have a question about global variables, too.
I created one called "Pixelate" with value of 150 (number).
I tried two events to remove -1 every tick and both seem to work:

Set Pixelate to Pixelate-1
or
Subtract 1 from Pixelate
and then it does:
Set effect Pixellate param 0 to Pixelate
I do this Every tick as long as Pixelate is > 1 and it seems to work well.

BUT when I change layouts to go to another screen and then come back the image looks like it was in the beginning with Pixelate set to 150. Is it normal for Globals to reset on layoutchange where the global is defined on the events at the first line? But it does not subtract 1 on the second view and stays pixelatet. :/

Bl4ckSh33p2013-07-23 18:32:11
B
47
S
14
G
5
Posts: 635
Reputation: 8,017


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 17 guests