Error "is not a constructor"

edited January 2017 in JavaScript Mode

Hi,

I created a Java game thanks to Processing and I wished I could show it on the Internet. In order to do it, I try to transform my Java codo to p5.js. However, I obtain the following error: "Monstre is not a constructor". I don't understand what i'm doing wrong. My code is available via this link: https://www.openprocessing.org/sketch/399217

Can you help me please?

Answers

  • edited January 2017 Answer ✓

    Monstre = new Monstre(600, 300, -1, 0, 0, 8, 2);

    In that statement, class Monstre is being re-assigned to refer to an object instead! :-SS
    After that, variable Monstre isn't a constructor function anymore! @-)

    Also, variables & non-constructor functions should follow the lowerCaseCamel naming convention.
    UpperCaseCamel is for classes and interfaces only! [-(

  • So object name small and class name Capital letter

    objects must have different name than the class

  • edited January 2017

    Thank you very much ! I'm stupid not to have seen it before :-SS

Sign In or Register to comment.