Global Variable Not Working

0 favourites
  • 4 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.
  • 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: docs.google.com/file/d/0Bz5x2REX7ZtRMlRjUDVoLWVaZEU/edit

    Sorry its sort of messy.

  • You are not resetting your global on restart, so it keeps counting.

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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. :/

    <img src="http://www.fotos-hochladen.net/uploads/globalsresetscgznbe1q0.jpg" border="0" />

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