multi npcs on 1 sprite

Get help using Construct 2

Post » Fri May 30, 2014 11:58 am

I have one sprite instance and have 12 npcs with their different walking animations for each direction.

boy1left
boy1right
boy1up
boy1down
boy2left
boy2right
boy2up
boy2down

How do i get it to play the correct direction with the correct boy?, i need the expression to say "whatever boy is playing and the direction".

set animation to "boy1" & "up" (the "up" part is determined by a value)

The above code works with fine with one npc per different object sprite but im trying to combine them all in one sprite. Can this be done?
B
14
S
6
G
3
Posts: 83
Reputation: 4,228

Post » Fri May 30, 2014 3:31 pm

Instead of using a static value to represent each and every action, use instance variables to represent which version to display.
I am assuming the list above of boy number and direction is what you name each of your animations.

Use a variable to store the selected boy number: BoyNum = 1
Use a variable to store the selected direction: BoyDir = "up"
Then when setting the animation set it to: "boy" & BoyNum & BoyDir
The above will result in the "boy1up" animation being played.
B
39
S
12
G
11
Posts: 331
Reputation: 7,727


Return to How do I....?

Who is online

Users browsing this forum: dop2000, Google [Bot] and 60 guests