22.05.2016, 20:08
(22.05.2016, 19:43)Xardas0327 Wrote:If I use this class, the error: hide() is not exist.Code:class Menu
{
constructor()
{
addEvent("onClick", login);
show();
}
function show()
{
setCursorVisible(true);
}
function hide()
{
setCursorVisible(false);
}
function login(button, x, y, wheel)
{
hide();
}
}
what's wrong? Is it impossible?
Is simply, because squirrel right now calling method as function. Difference between function and method is that, method need object for call.
Example:
function(); // Calling function
obj.method(); // Calling method, as u see object is needed
But addEvent second argument is a function, so in timer code it look like:
login();
not
obj.login();
Squirrel don't know, which object should be called, and login method is called as function, so in code we looking for function hide, not method

Maybe is hard to understand, but is logic.
To fix this problem, create function outside the class.