0 Favourites

A question about text and global variables

  • What should I do to force the text to retrieve information from global variables? In events, I did:

    System Every tick Text1 Set text to "Score: " & Score

    Why doesn't it work?

  • It does work. Did you save Score as text "" or number 0 because text will show nothing "" unless you put something in it and number should show 0.

    Is your text box big enough to show Score: 0...

    And don't use everytick, only update the text file when the score updates...

    Post a capx, so we can see where you went wrong - because it does work.

  • Can you please explain more clearly? I am new to Construct 2.

  • And How should I do this the right way that it updates every time when global variable changes?

  • OK, here are the screenshots. I've got the Event Sheet and the Layout. Sorry for spamming messages if it annoyed you.

  • if your global variable is a number then that is the reason I think. A number is a type called "number". The text object only takes data in the "text" format. If you want to use data of the type "number" in text you might need to surround the number with "str(...)" when you set the text. Like this:

  • And How should I do this the right way that it updates every time when global variable changes?

    Hi, you have an event 'on collision with sprite6' you could update the text in tne same event.

    ON collision with sprite6:

    Destroy sprite6

    Add 1 to score

    text = "score " & str(score)

  • It's still not working and (I think it's a bug) in 'Good job' layout, there are platforms (they are sprites, ofc) that I placed on 'Level' layout, but not on the said 'Good job' layout. The platform bug happens only when I play my game, but not when I'm editing it. Why is it this way?!

    Getting back to my first question, here are the screens (one is the Event Sheet, the other one shows what the text is actually indicating when I play the game and the bug with platforms that shouldn't be where they are):

  • Hi, if you post a capx, others will be able to help you much easier.

    If you don't want to share your game, then make a capx that illustrates your problem. If we can't see what you are doing in your code then it is a bit hard to help.

  • try this and see

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • What is a capx? and how to use this Score.capx from Lordshiva1948?

  • What is a capx? and how to use this Score.capx from Lordshiva1948?

    SadisticDentist Seriously?

    Okay, I suggest before you do anything... read the manual

    Do the example games, don't just look at it or copy and paste. I want you to recreate it line by line.

    tutorial one

    tutorial two

    All new folks say, but that isn't what I want to build. Understand that they cover the basics, and the basics is what you use to create any game. for example in the first one shows you how to use text and global variables i.e score

    The example from lordshiva1948 requires latest stable release and a external plugin - so it isn't going to help you. Do the tuts I linked to, they have all the basics, and the answer to your question(s).

    Roll up your sleeves and learn the tool (construct2) it is a fantastic program that rewards those who spend time learning how to use it.

  • OK, here is the capx. And just one question: can I change the order of the layouts in my game?

  • OK, here is the capx. And just one question: can I change the order of the layouts in my game?

    Wow, you seriously need to follow my advice and do some practice with examples.

    More resources would be to open your C2 click new and scroll down that huge list of "GOLD"

    Your capx is a great 1st attempt, but you need to learn how to do things properly else you are going to pull your hair out later on.

    To answer you question - Yes you can and I presume you mean change order as to what is your first layout then yes you can, click on project file in right top panel and change project property settings first layout to whatever you want to load first.

    This is basic stuff, covered in the manual.

    Good luck, happy learning...

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