How do I make a position assigned to a single variable ?

0 favourites
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hello,

    In Unity C# we can use Vector 2 and 3 to set varibles that contain more than 1 value. A great example is if you want one variable to hold an RGBA color value. You would set the Vector4 to:

    myColorVariable = New Vector4(000,000,fff,fff);[/code:v4en9d8v]
    
    This is extremely helpful when drawing boxes or setting something's position... (just use a Vector2(X,Y) for the X and Y value.)
    
    What I am wondering is if we have something like this in Construct2?
    How would I set a single varialbe to an objects X and Y position?
    
    I can see we have something to set and return RGB values. This is why I am asking.
    
    Thanks in advance for any help.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No you'd have to simulate something yourself using arrays and maybe wrapping it in a function but I'm not sure it would be worth the trouble.

  • Thank you codah

  • I really wish C2 had these

  • I really wish C2 had these

    Do you think someone could do it with a plugin? I wonder if HTML5 uses them?

  • Nah, it's definitely a limitation of the editor. I don't even know if js supports them.

  • There's a way you can do it, actually. With weird integer encoding. >.> Let me see if I can't whip up an example.

  • you can do it with arrays setting different arrays to different RGB codes then just load that

  • Nah, it's definitely a limitation of the editor. I don't even know if js supports them.

    Was looking into this further and JavaScript does not even have an integer. It just rounds float values. I have a feeling vectors where something extra special that they added to Unity or Mono.

  • So, here's two numbers encoded as one. It gets trickier if you want more variable-sized numbers...

    And it's definitely more trouble than it's worth.

  • Thanks lord shiva

  • So, here's two numbers encoded as one. It gets trickier if you want more variable-sized numbers...

    And it's definitely more trouble than it's worth.

    Very cool, thanks!

  • There's a way you can do it, actually. With weird integer encoding. >.> Let me see if I can't whip up an example.

    I don't think there's any doubt it can be done, but it will never be recognised natively by C2. Not sure if its worth it for a bit of syntactic sugar, but to each his own.

    edit: whoops missed the last few posts. My statement still stands though

  • The other way to sorta do that is to have an object with instance variables. That's a little closer- have a sprite called Vector4, and instance variables called One, Two, Three, Four, etc... Again- not worth the trouble. Still fun to consider (briefly)

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