Initialize A Class

แชร์
ฝัง

ความคิดเห็น •

  • @qooldeluxx
    @qooldeluxx 2 หลายเดือนก่อน +1

    well i learned something new, thanks

  • @Shanjaq
    @Shanjaq 2 หลายเดือนก่อน

    6:35 the only error I've seen with _init that ppl might be mentioning, is that once you've defined an _init with args, and you try to extend the class, it will complain that _init (with no args) doesn't exist. in that case I just go back and define a default _init with no args, which is a little annoying when you *must* use args to properly initialize the class so you've just created a pitfall for your future self where the engine won't complain when you use the default _init but the resulting instance will be invalid.

    • @GlitchedCode
      @GlitchedCode  2 หลายเดือนก่อน

      Maybe I am misunderstanding something here.
      I just created a new class and defined its _init, the dog class in the video
      I just extended dog to another class called OtherDog
      OtherDog has its own _init, tested with and without arguments and no errors.
      If I want to initialize the Dog class that OtherDog is extending, from OtherDog I can call super() and pass in the arguments Dog needs. Name, Breed, and Age in this case. I have no errors with and without calling super as well.

    • @Shanjaq
      @Shanjaq 2 หลายเดือนก่อน

      @@GlitchedCode yeah it's probably a squirrely editor issue that changes version to version of Godot, that's just one of the things that came to mind when you mentioned that ppl were having issues with the builtin _init but couldn't explain it every time 🤷‍♂

  • @spleenvitals
    @spleenvitals 2 หลายเดือนก่อน

    HOW THE FUNC DID I NOT KNOW ABOUT PRINTT ?????? Thank you! Also never thought to hit underscore and just read the functions. 😅

    • @GlitchedCode
      @GlitchedCode  2 หลายเดือนก่อน

      Glad you learned something lol