Struct confusing declaration

Comments

4 comments

  • Core Tech

    You cannot use an anonymous function as a constructor it must be named, this is intentional

    you can however create a struct literal if that is what you want to do

    i.e.

    var vec2 = { x: 10, y : 20 };

    but you cannot use the syntax in your first example to create a constructor

    Russell

    0
    Comment actions Permalink
  • Cesar Ottani

    Thanks for the fast response! =]

    So, I just got confused by the documentation under Structs tab. One time it states that Vector2 like above, then it make it correctly on Vector3.

    I don't have a documentation link, I am accessing it only inside GMS. Is there an external link?

    0
    Comment actions Permalink
  • YoYo QA Dept

    Hi Cesar,

    The documentation for the new features is only accessible through the Beta IDE at the moment. 

    What is the title of the manual page that you are referring to in the comment? We'd like to review it to make sure it has the correct information.

    Thanks,

    Alice 

    0
    Comment actions Permalink
  • Cesar Ottani

    The manual title is Structs and have the following code:

    Vector2 = function(_x, _y) constructor
        {
        x = _x;
        y = _y;
        static Add = function( _other )
            {
            x += _other.x;
            y += _other.y;
            }
        }
    0
    Comment actions Permalink

Please sign in to leave a comment.