How do I read values from TextBox (created during execution)

0 favourites
  • 3 posts
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • Hello,

    I like to write a game which is a little bit equal to the boardgame "Robo Rally"

    boardgamegeek.com/boardgame/216 ... rally-2016

    Here you can program your robo like

    "move 2 steps"

    "rotate"

    "fire"

    So I like to create a kind of UI where a user can add (click on a button) actions e.g. move x steps, rotate, fire (realized by different sprites).

    The creation of the button which will add these actions is no problem but then it get complicated.

    My idea is to use a pointer (sprite) which will check if it is overlapping with an "action-sprite" and trigger the connected action.

    What I do not know is, how can I read the values from the "TextBox" which belong to the "action-sprite" and define e.g. amount of steps?

    If you also have some hints how to realize this more easier I would be very happy.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I dont know if its what you want, but I will try. You can add a mouse object (or touch if it's on mobile). After that, in your event sheet it's supposed to be similar to this:

    On left button clicked on MoveObject (or on object clicked on touch, if it's mobile)

    >Move forward of 50 pixels

    This is only an example. You can change the object and the move for rotate, for example

    For a text box, me I put a global variable (if it's for a'll of your layouts) or a variable on your textbox (if it's only for this layout) And you put that in your event sheet. Note that the variable needs to be a text, not a number or a boolean

    Every tick : Set variable to textbox.text

    For displaying it, there can be another event Every tick but with the action Set text to variable.vale

  • Hey mrkaio!

    Big fan of RoboRally here. I already implemented something like it in Construct 2 but I don't have the file here (at work right now). I recommend you use an array for storing "robot actions". Since there is a limited collection of actions, just use an ID for each of them and store them in the array when players do the programming. When you need to execute the actions, check each array position in order and play the corresponding animations.

    If you prefer to use the approach you mentioned, you can easily read the content of a TextBox using the property TextBox.Text.

    Hope this helps. Cheers!

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