How do I pick a sprite based on instance variable?

Get help using Construct 2

Post » Tue Dec 29, 2015 7:18 am

I have a player sprite and 10 home sprite instances. Each home sprite has variable called location, and each has their own number (Home.location=2, Home.location=3, etc.).

Whenever I click a home sprite, I want the player sprite to move to a certain home sprite. So if I click on any home sprite, I want the player sprite to move to the home sprite with instance variable of 6.

On tap gesture on Home = Player move to Home.X(with the instance variable of 6), Home.Y(with the instance variable of 6)

How do I code this in the X and Y co-ordinates??

I tried tried this

On tap gesture on Home = Player move to Home(Home.Location=6).X, Home(Home.Location=6).Y

but the player keeps moving to the home sprite with the instance variable of 0.

Any help is appreciated, Thanks!
B
11
S
3
G
1
Posts: 26
Reputation: 1,288

Post » Tue Dec 29, 2015 8:12 am

conditions:
on tap
system / pick by comparison
object = home
expression = home.Location
value = 6

action:
player move to home.x home.y
Image
B
82
S
30
G
12
Posts: 517
Reputation: 12,763


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 26 guests