[Suggestion] Sprite type variable

0 favourites
  • 14 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • 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!

  • Isn't that what families are for? Maybe I'm misunderstanding exactly what you need.

  • 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 :)

  • 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)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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

  • 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.

  • 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 .

  • 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

  • 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 ?

  • Why doesn't the OP just use Frames and Animation groups in the Sprite?

    I noticed new developers don't grasp some of the tricks of the trade for C2 and often bloat the number of objects used.

    I assure 100% there is a way to do what the OP wants without making any changes to the C2 game.

    Here are the suggestions I have.

    1. use Frames and Animation Groups to distinguish your "skins".

    2. Use 1 object for logic. Then use different graphic sprites/frames/animations for skins.

  • Hi people,

    Thanks for all your replies!

    I probably am doing too much thinking in a programming mindset instead of a C2 mindset.

    Kyatric and Jayderyu: yes, you are probably right. This should be the easiest way to accomplish what I'm looking for.

    Next time I'll just ask a question first before making a suggestion. :)

    Thanks!

  • What an entrance to the community...silly me <img src="smileys/smiley36.gif" border="0" align="middle" />

  • Don't worry, you're the not the first and certainly not the last to do so ^^

    The community is open to communication anyway, so no problem.

    It's just, take the time to get used to Construct2, it's been around for long enough now so that its own ways will cover beginner to advanced users needs.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)