Quick question about tweens!

AJ Studios

I was writing the code as I was going through the lesson and when I wrote the last line of code, I wrote Tween.start( ) instead of tween.start( )  with lower case letters. This returned a big fat error: 

Non-static function “start” can only be called from an instance.

I corrected this by writing tween in lower case but I couldn’t see any reference to this on the documentation, perhaps I missed it. What is the difference between “Tween” & “tween”?

Thanks in advanced!

Btw, this is in reference to Door.gd

  • a
    andrewjhaugen replied

    Tween with a capital T refers to the class itself! This analogy isn't going to be 100% correct but it will help to get the idea across so bear with me:

    The class itself (Tween with a capital T) is like the abstract concept of the thing, think of it like the blueprint for building a Ferrari. Yes it has all the instructions for constructing the Ferrari, but can you take the blueprint itself and go driving? Can you go down to the grocery store driving a blueprint? I don't think so right...

    tween with the lowercase t is the actual object that you have constructed. This is like taking the blueprint that is Tween with a capital T and then building an actual Ferrari with it. Now your tween (with lower case t) is an actual factual car, and now you can do things with it like drive to the store, honk your horn etc.

    The blueprint of the Tween (the capital T) can't do any actual work it's just the instructions
    the object tween (the one with lower case t) actually can do the work, like call methods such as start() stop() etc.

    Hope that helps!

    1 love
  • AJ Studios replied

    I see, this is actually a good analogy and it makes sense. Once I finish the course I will look into classes, types, etc… I’m still lost when it comes to that. Thanks again, your explanation really did help me in understanding the difference.