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

Get help using Construct 2

Post » Wed Aug 16, 2017 3:21 pm

Message: mrkaio can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Hello,

I like to write a game which is a little bit equal to the boardgame "Robo Rally"
https://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.
B
3
Posts: 2
Reputation: 184

Post » Sat Nov 04, 2017 11:18 am

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
Go try my game Shooter Interstellar!Also useful nature game assets for your game! Nature Pack
B
27
S
17
G
13
Posts: 91
Reputation: 9,396

Post » Mon Nov 06, 2017 12:01 pm

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!
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
22
S
6
G
3
Posts: 722
Reputation: 4,026


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests