Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
As I remember, createGraphics() should work in other p5 methods such as draw() and mousePressed() as well. The problem you have might be you are trying to access p5 methods before p5 is initialized (in setup() usually). You can try ensuring the p5 object is initialized either with instance mode or by making sure setup is called before making other calls to createGraphics() in other objects etc. You can look at #903 about this. And this.
Let me know if that's not the case.