(SOLVED) How do I change the player sprite with another....

Get help using Construct 2

Post » Tue Mar 04, 2014 3:03 pm

Hi friends!!!
Is it possible to change the player sprite with another maintaining the same name so to maintaining also the animations and all the instances ?
I mean that if it was possible to "load" the player sprite from a file, so in this case I would have the same instances and animations name.

any advice would be appreciated!!! :D
Last edited by argail on Wed Mar 05, 2014 2:11 pm, edited 1 time in total.
B
9
S
2
Posts: 117
Reputation: 1,009

Post » Tue Mar 04, 2014 3:06 pm

well. juste open your sprite and "open file" and chose another image. The name doesn't change
B
13
S
4
G
1
Posts: 241
Reputation: 1,724

Post » Tue Mar 04, 2014 3:11 pm

You would also need to change the animations.
I will not let you reach the sisters
Nature Forums
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

Post » Tue Mar 04, 2014 4:50 pm

Sorry, I have explained badly...
I want to open the "new player" sprite file from the event code..... I need this because i want to use another player sprite when for example the player evolve in other sprite.
B
9
S
2
Posts: 117
Reputation: 1,009

Post » Tue Mar 04, 2014 4:59 pm

The way I usually handle that is to use an invisible sprite for the player - to keep instance variables, the position on screen, and keep all the events as simple as possible. Then you can pin any sprite you want on top, change animations as necessary, etc...
B
99
S
35
G
20
Posts: 438
Reputation: 17,910

Post » Tue Mar 04, 2014 5:40 pm

Much easier than using "another" sprite is to simply add it as another animation to your existing sprite. If you really need to use a different sprite, then AllanR is on the right track. Use an invisible sprite as your actual controllable character and just pin a visible sprite to it and that is what the player sees. You can then just pin whichever sprite you want as the visual representation of your character.
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,603

Post » Tue Mar 04, 2014 8:40 pm

Here an example of the code where the player goes left and right with animation "sinistra" and "destra".

Image

Now.... I want to "load" or something like that and replace the "pg" sprite with another sprite that have the same name and same names of all animations, in order to avoid to reprogram all the instances.
Something like that :
_ load sprite "pg1.png" to PG SPRITE ( i cant choose from two or more player sprite, for example : pg1.png, pg2.png etc... )
_ right arrow is down -> PG SPRITE set animation to "right" etc....
So the name PG SPRITE remain the same, and all the animations like "right" , "left" , "jump" etc. remain the same.
I hope it's clear now, i'm sorry for the bad english! :D
B
9
S
2
Posts: 117
Reputation: 1,009

Post » Tue Mar 04, 2014 8:54 pm

Yes, i can add many animations as many different player i need, but in this case i need to duplicate all the code in order to check which sprite i'm using in that moment.
For example:
Animations
- left, right, jump, etc.. (with the image of the first player for example a dog!)
-left, right, jump, etc.. (with the image of the second player for example a cat!)
and so on...
Is this the only solution ?
B
9
S
2
Posts: 117
Reputation: 1,009

Post » Tue Mar 04, 2014 9:00 pm

It's possible to use : set animation to "left"+ x ?
so in the code i will use: if PG = 1 then X = 1
and in the animations panel : left1 of pg1, left 2 of pg2 , etc...
I cand happend a string to another ?
B
9
S
2
Posts: 117
Reputation: 1,009

Post » Tue Mar 04, 2014 9:19 pm

Ok, i used a global text pgused = "1"
player1 set animation to "left" & pgused (in this case will play the animation called "left1")
It works well!
B
9
S
2
Posts: 117
Reputation: 1,009


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests