Using function and objects

Get help using Construct 2

Post » Sat Aug 10, 2013 4:30 pm

I'm having some issues implementing something in my work.
What i want to achieve is: i need to display some texts in some text objects, but the object i display the text in depends on some other things, so i need to implement a function that would be able to take in the parameter of which text object to set the text to at that particular time.
I'm not sure on how to implement this even using UID
B
15
S
4
Posts: 138
Reputation: 2,003

Post » Sat Aug 10, 2013 4:45 pm

SetTextByUID.capx
If you have different Text objects, you just put them in a Family and pick by the Family.
ImageImageImage
B
71
S
21
G
204
Posts: 3,586
Reputation: 115,576

Post » Sat Aug 10, 2013 5:36 pm

@blackhornet, thnaks. but i'm still yet to figure out how to make it work for what i want to do. Please take a look at my .capx file here
https://www.dropbox.com/sh/v8etbkbivfl427l/E-rqkqk186
B
15
S
4
Posts: 138
Reputation: 2,003

Post » Sat Aug 10, 2013 6:13 pm

I'm not following completely, but if you move the 'setTextByUID' call to after the 'Set i to i+1', it's closer. (Make your text box bigger so you can see the value.)

You shouldn't be using hard coded UID numbers. They aren't guaranteed. It's better to have your own addressing scheme via an instance variable.
ImageImageImage
B
71
S
21
G
204
Posts: 3,586
Reputation: 115,576

Post » Sat Aug 10, 2013 6:24 pm

That's the challenge, the setTextByUID call cannot be in that group as the parameter (UID) passsed to it is expected to change depending on when it is called.
B
15
S
4
Posts: 138
Reputation: 2,003

Post » Sat Aug 10, 2013 6:59 pm

upload a JPG or GIF to show what you're trying to do.
B
18
S
5
G
4
Posts: 568
Reputation: 5,079

Post » Sat Aug 10, 2013 7:03 pm

So how are you determining when to call the function?

You've got the basics. Determining which Text object you want and passing in the UID, to be picked, will do what you need.
ImageImageImage
B
71
S
21
G
204
Posts: 3,586
Reputation: 115,576

Post » Sat Aug 10, 2013 11:50 pm

@blackhornet, simply put for that sample file u created to xplain, I do I get to to set text for only one of those instances at a time instead of d for each you used(imagine dat program is meant to set txt for only say the second instance). Or what if those text objects were actually different objects, how do I set text to each of the at different point in time by calling a single function.
B
15
S
4
Posts: 138
Reputation: 2,003

Post » Sun Aug 11, 2013 12:35 am

RandomFunctionFamilySample.capx

Families take care of the different objects. This just randomly picks an instance, from a timeout, and calls the function which picks the appropriate Text object by UID, and sets the text to the value passed into the function.
ImageImageImage
B
71
S
21
G
204
Posts: 3,586
Reputation: 115,576

Post » Sun Aug 11, 2013 5:15 pm

@blackhornet, thanks a lot family really handled everything i wanted to do. You are the best
B
15
S
4
Posts: 138
Reputation: 2,003

Next

Return to How do I....?

Who is online

Users browsing this forum: CJacobsSA, Exabot [Bot] and 4 guests