How do I Animations from frames

Get help using Construct 2

Post » Thu Aug 04, 2016 9:24 am

If it's just about changing skin of the character and all skins have the same animations names then the proper way would be to create an invisible player sprite which will have all control/movement events and each skins as a separate sprite with proper animations groups.

Now whenever you need to change the skin you simply spawn the skin sprite on the player sprite and pin it to the player. As all your skins have the same animations (walk, jump, attack, ...) you simply run the set animation function with the proper param ("walk", "jump", ...) in a generic way, so one code will work for all the skins.

Why do you worry about "copy events for each created sprite"? Events go to player and skins are just animations, so you don't need any control, collision or whatever events on them.

Also this way you keep the code clean and easily maintainable. If it's a big project then I strongly suggest to focus more on proper code rather than on optimisation which in this case won't give you much advantage if you put all in one sprite. Even more... one sprite with tons of frames (all skins) will be pretty memory consuming for no reason as I assume you will not use all skins in each layout?
ImageImageImage
B
31
S
19
G
82
Posts: 1,037
Reputation: 46,203

Post » Thu Aug 04, 2016 10:55 am

@IGDev
If you choosing my example and want skin change on this
then I made this for you
Image
B
72
S
41
G
48
Posts: 685
Reputation: 34,286

Post » Thu Aug 04, 2016 3:10 pm

Name your animations accordingly. For example for the red skin, name the running animation to red_run. For the blue skin, name the same animation to blue_run. Then use variables to store which skin is active. Then you can call the required animation by building up it's name in an expression: variable_skin&"_run"
B
136
S
33
G
17
Posts: 1,560
Reputation: 20,775

Post » Fri Aug 05, 2016 2:08 pm

You don't need to have all animations for one specific character in a single animation group.

You can have;
Variable.CharacterType="whatever" (fighter,mage,archer)
variable.CharacterAction="whatever" (walk,attack)

Then do:
set animation -> Variable.CharacterType & Variable.CharacterAction

"FighterWalk"
"FighterAttack"
"MageWalk"
"MageAttack"
"ArcherWalk"
"ArcherAttack"

^Possible combinations from one event listed^

If you have some way to tell the type of character already, then you can simply do it like this and save a lot of headache. I guess the best benefit of it would be if you decide later to add extra animation frames or something - you will be adjusting all kinds of frame numbers and stuff later on.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Fri Aug 05, 2016 11:01 pm

@luckyrawatlucky thanks i think your solution is best because is most siplier and smaller
B
25
S
8
Posts: 219
Reputation: 2,181

Previous

Return to How do I....?

Who is online

Users browsing this forum: dop2000, Maako, max2612 and 6 guests