Why can't I name animations numbers (like "1")? Workarounds?

0 favourites
  • 4 posts
From the Asset Store
3 pixel charaters with over 8 animations each + animations with a gun
  • Hello people.

    Problem: I am not allowed to name an animation a simple number such as "1" or "34". It just reverts the name back to the previous one with no error message or reason why it doesn't work. I don't know if this is a bug or intended, I guess intended to stop certain stuff?

    I want to spawn random background objects in my side scrolling game. The way I have been doing this is using tons of events and sprites each individually looking something like "if level = 1, Every random(3,6) seconds create object cloud1" etc...

    Now I would like to make a big "BGobjects" sprite that contains tons of animations and frames for the various BG objects I need. I can simply name each animation 1 2 3 4... for each level they go into and do then the following:

    Every random(3,6) seconds create object BGobjects

    set BGobjects animation frame to Level (So on level 1, it will be all the level 1 objects, level 2 they'll all be level 2...)

    set BGObject frame to choose (1,2,3,4) for the 4 different kinds of clouds that fit into level 1. Or the 4 different kinds of bubbles that fit the underwater level 2. Etc.

    This would work seamlessly and use very few events, if only it allowed me to name the animations simple numbers in the first place...

    The only theoretical workaround I can think of but have not tried yet is to simply call the animations fitting names such as "Clouds" "Bubbles" and then simply add a global variable called "AnimationHelper" and 4 events like (Level = 1, set AnimationHelper to "Clouds") (Level = 2, set AnimationHelper to "Bubbles")

    And then just

    set BGobjects animation frame to AnimationHelper

    Same thing but a little more convoluted, should work though, right? Any better ideas? Any explanation on why I'm unable to name an animation a number? Thanks.

  • Or you could add something to make the name longer, like "Animation1" "Animation2" "Animation3" and then just do a Set animation to "Animation" & AnimationNumber <== Your variable sort of thing.

    The problem with "short" names I think lies not in shortness, but in it being a number.

  • You generally can't name things with a number, because it makes it ambiguous whether a name is a name or a number. The best example is with object type names, where they can appear in expressions e.g.

    Sprite.X

    If you could call a sprite "34" then it appears as

    34.X

    which is difficult for the parser to figure out what you mean (since 34. is a valid floating point number). That doesn't exactly apply to animations, but for consistency and future-proofing the same principle is applied nearly everywhere. Workaround: use names like "a1", "a2", "a3"... and set the name "a" & number.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for both of your responses, you've cleared it up and gave a better compromise than the one I came up with.

    Cheers!

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