lives and scores

  • zenox > it's an ergonomy problem then. But I don't think the "global" option should be disable. For one reason: it could be used effectively we just never encounter a case where it was.

    The more option the better, even if confusion can arise. People will ask, and learn some concept through design mistake.

  • Thank u zenox98 & Yann for ur help.

    I set both text boxes to non global and it works fine in my game, but I'm not really figured out why they are missing while they are global. May be it's just as zenox98 said after restart the game they transfer to layer one.

    zenox98 "Personally, I just think the use of global objects is ambiguous, and not readily understandable to the layman. Users are probably expecting these global objects to appear on all layouts, which without extra coding, they won't." That is exactly what i thought first "before this post"

    Yann "How it was used in Mina's capx is not a proper use of global object. Global object shouldn't even be used for Graphical representation." So how can i post the lives and scores in a game without using graphical representation and why it has the ability to be global if i can't use it?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The ability to be global exist 'cause it's possible. That is to say, you can have persistance of object through layout.

    But for graphical object (I mean by that object that draw something on the layout (sprite, text, tiledbackground)), I don't think it's necessary and it leads to problems as the one we just encountered that is "where do you put global object when you don't have the same layer structure in different layout?"

    For score and live representation, you just need something that would display it in each layout. What you want to be global (that is to say travel through layout) is data. It's just the number you don't want to be reset.

    The graphical stuff... there's no reseting, it's juste your sprite and text boxes you use to display your game.

    So for lives and score, just use global variables to keep them

    and in each layout

    system: every tick
         -> TextScore: set Text to score
         -> TextLife: set Text to lives

    TextScore and TextLife are Text object but they doen't need to be global, it's the variable that need to be, the data.

    And as I said in a post long time ago, there's generally not that much global stuff in a game.

    Unless you want a big stat layout with number of kill, number of death, precision of shoting, etc

  • Extract from the manual article about instances:

    y default, all instances are destroyed when the layout ends (e.g. when going to the next layout). If Global is Yes, none of the instances of this object type will be destroyed when switching layouts.

    Consider this example

    The object Text is set to global.

    I have an instance of Text in layout 1.

    Layout 1 automaticly switches to layout 2 after 2 seconds.

    Result => the button instance of layout2 appears, the text instance of layout 1 stays on screen.

    Clicking the button allow to make a new instance of the Text object.

    Now if you turn global to no on the Text object, observe:

    On layout switching, the Text instance from layout 1 disappears (gets destroyed).

    Still you can create a new instance of Text on layout 2. The object Text itself is "global"/reachable from the whole project.

    The sprite in layout 2 is global.

    Clicking it leads to layout 3.

    The button2 in layout3 just takes back to layout 1.

    You can see with global set to yes, from now on, the Text instances and the sprite appear in every layouts.

    Global only apply to instances, not to the object itself. Every objects are "global" to the project by default.

    In mina's capx, I think the trouble comes from the layer.

    In the "startup of layout" of Event sheet 1 (event 64), you have to "move to layer 3" for text_lives, sprite2 and text_score.

    Make an experience, make sprite4 in layout1 invisible (it is the background, btw mina, you should rather use a tiledbackground object than a sprite there, you could then use a smaller texture (base png) that will repeat itself automaticly and make the project and then download of the game in the end smaller, so better).

    You can see, the instances of text_lives, etc... are on layer 0 (they stay in place when you move to the right).

    In fact, each time you execute the layout 1 again, the sprite4 of background gets drawed over the global instances that traveled through the different layouts, keeping their properties.

    zenox98: It makes sense that they don't get moved back automaticly to the layer3. In fact in the case of non global instances, they would be moved/spawned back. The instance is set for this specific layout.

    But since you're using global instances, that are non limited to a specific layout, it's your responsability to move/handle them.

    The layout sort of "ignores" them.

    I must admit I was confused with this too. Reading the manual and testing in C2 helped.

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