[Suggestion] Sprite type variable

Discussion and feedback on Construct 2

Post » Thu Dec 19, 2013 6:04 pm

Hi,

As far as I know it is only possible to create a sprite/object by picking one from a determined list.
Being able to create/manipulate an object by using a variable (that holds a string that matches a certain object name in the project window) would seriously improve flexibility and reduce code.
As such one could make a function that creates and manipulates different sprites in the same way in 1 routine instead of having to copy the routine for each object. Using UID's doesn't cut it, because it is not always pre-determined what object needs to be created/manipulated.


My use case is skinning. I want the user to be able to choose between various skins for a card deck. Each card in my project consists of 4 sprites (to be flexible in animations and overall filesize).
The sprites are obviously used throughout the game logic.
So in my case at this time, it would mean that I need to copy +150 events and many more actions for each skin to complete this task.
I'm at 206 events total, and the game is not nearly finished. If I want 4 skins this would easily become 650 events, instead of the 215 or so when being able to use a variable type: Sprite.

I hope you will seriously consider looking into this Ashley! I can think of many more cases where one would tremendously benefit from a Sprite variable.

Thanks!

B
8
S
2
Posts: 26
Reputation: 604

Post » Thu Dec 19, 2013 6:07 pm

Isn't that what families are for? Maybe I'm misunderstanding exactly what you need.
B
60
S
20
G
56
Posts: 1,077
Reputation: 35,941

Post » Thu Dec 19, 2013 6:22 pm

I have a game logic with 150+ events that use a certain number of sprites.
If I want the user to be able to choose a different set of sprites before the game starts (before I create the containers, and create the sprites), I have no choice but to copy the whole gamelogic and change events and actions to use other sprites.
I basically need to copy the whole game just to alter the look of an object.

In my case I want the user to be able to choose a skin for a deck of cards. Each card consists of 4 sprites.
But the problem could also arise if you want the user to choose between a large number of avatars or player characters that need to be composited at runtime.

Not being able to put a Sprite object into a variable creates a big overhead and causes tedious, unefficient programming in these cases.

I guess there is a way which involves putting in the graphics for different skins into animation of 1 object/sprite but that would complicate gamelogic programming unnecessarily. And that would still limit possibilities/efficiency compared to a Sprite var.
Hope I'm not overlooking a clean solution, I've looked for it long...and hard. I hope I'm not blind :)Moongaze2013-12-21 00:15:59
B
8
S
2
Posts: 26
Reputation: 604

Post » Thu Dec 19, 2013 6:26 pm

@Moongaze search for "nickname" plugin (man this plugin should be stickied somewhere, this is the thirth time im referencing it in a couple of days)
ImageImage
B
69
S
21
G
7
Posts: 827
Reputation: 10,017

Post » Thu Dec 19, 2013 6:39 pm

@vtrix

Thanks! That looks like the exact thing I'm looking for !
I hope it 'll work, I've encountered strange behaviour using plugins and some just crash at runtime.

Regardless of that plugin, I should say that construct would be even greater with more variable types.
B
8
S
2
Posts: 26
Reputation: 604

Post » Sat Dec 21, 2013 12:10 am

@vtrix
I took a look at the plugin but it is not nearly adequate enough.
There does not seem to be a way to manipulate position, alpha etc... or pick nickname instances by instance variables ot other parameters.

Thanks for the suggestion though.

@Ashley : I have seen that other people suggested a variable type sprite as well on the forum. Is this somewhere on the development roadmap?

Thanks
B
8
S
2
Posts: 26
Reputation: 604

Post » Sat Dec 21, 2013 1:23 am

@Moongaze , everything you create can be manipulated however you want in the same action or save the uid to a variable and the instance can be recalled, if you have trouble doing something, you can post a simple capx and ask what you want to do, im sure someone or me are happy to help or try to help you.
ImageImage
B
69
S
21
G
7
Posts: 827
Reputation: 10,017

Post » Sat Dec 21, 2013 2:11 am

um the person above me is right that is what familys are for. What you need to do is something let this. make a family include all the card spites then on each card add all the different colors. then make a global variable that u +/- to each time the player changes the skin ... and you make a event that then that changes the familys animation frame to the global variable .volkiller7302013-12-21 02:13:40
B
42
S
17
G
2
Posts: 850
Reputation: 6,209

Post » Sat Dec 21, 2013 2:43 am

@volkiller730 , yes but using multiple families will make maintenance and logic harder, by using nickname plugin to create the objects, i would put everything (all cards, all themes) under one family and differantiate by variables, once you created the cards for the right theme, all logic will be on one family, by using a string construction you could call the right cards, ex. theme1_card1, not sure for this last thing, but i think you can loop thru the family and autoname the nickname
ImageImage
B
69
S
21
G
7
Posts: 827
Reputation: 10,017

Post » Sat Dec 21, 2013 4:38 am

Wouldn't it be simpler to use different animations in a single sprite and switch between the animations ? (The frame numbers/logic would still be the same).

Or am I missing something ?
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,319
Reputation: 87,487

Next

Return to Construct 2 General

Who is online

Users browsing this forum: JaredX, megatronx and 1 guest