build a variable with a string and a variable

Get help using Construct 2

Post » Thu Jun 06, 2013 9:19 pm

Hello (excuse my english)

For example i want to call sprites in Event Sheet : sprite1.x , sprite2.x sprite3.x sprite4.x...

numpoint is a variable

That looks like it : "sprite"&numpoint&".X"



but it does not work.

how the concatenation string and variable works ?

Thank you.
B
12
S
3
Posts: 140
Reputation: 2,005

Post » Thu Jun 06, 2013 9:27 pm

@chrislechat if I understand correctly you want to do

"sprite"&str(numpoint)&".X"

I am assuming numpoint is a global. If it is an instance variable of sprite it would be

"sprite"&str(sprite.numpoint)&".X"
B
37
S
9
G
5
Posts: 437
Reputation: 6,094

Post » Fri Jun 07, 2013 9:45 pm

Hello,

I tried but it shows me this message (see print)

pointpath is name of sprite.


B
12
S
3
Posts: 140
Reputation: 2,005

Post » Fri Jun 07, 2013 10:12 pm

try using the turret behavior?
B
40
S
11
G
7
Posts: 514
Reputation: 9,626

Post » Fri Jun 07, 2013 10:19 pm

Hi,
You can't really do that, you'll have to put all your pointpath in an array and use "numpoint" as an index
B
13
S
3
G
4
Posts: 69
Reputation: 3,449

Post » Sat Jun 08, 2013 6:01 am

Correct format would be: "pointpath " & numpoint & ".X". Couldn't really understand from your events what you were trying to achieve there? :)
B
24
S
9
G
7
Posts: 756
Reputation: 7,292

Post » Sat Jun 08, 2013 10:31 am

I think he have objects called pointpath1, pointpath2, pointpath3 etc... for exemple and try to access the X value of these objects so he try to concatenate strings to form a variable. He have to use an array to do that
B
13
S
3
G
4
Posts: 69
Reputation: 3,449

Post » Mon Jun 10, 2013 9:24 pm

Thank you
B
12
S
3
Posts: 140
Reputation: 2,005

Post » Wed Jun 12, 2013 9:12 am

Can anyone give an example of how you would do that with an array? I have a similar problem, but I don't really understand what you meanYanen2013-06-12 09:13:01
B
18
S
3
G
1
Posts: 35
Reputation: 1,875


Return to How do I....?

Who is online

Users browsing this forum: ColombageEnPLS, gianghl1983 and 11 guests