To get a clean code, I would like to add functions to the player object.
I do :
var me = Spark.getPlayer();
var opponent = Spark.loadPlayer(otherPlayerId);
So I can call functions associated with player object :
var nb = me.hasVGood("coin");
var nb = opponent.hasVGood("coin");
What I would like is also to call functions that I write mySelf :
me.myFunction();
opponent.myFunction();
=> Where and how can I define "myFunction" ?
I know I can define this function in a module and pass the player object as parameter, but it would be cleaner if I can encapsulate all functions on the object.
Thanks for advice
Best Answer
C
Customer Support
said
almost 7 years ago
Hi Eric,
Currently this method is not supported on the platform.
As you mentioned, you can define those functions in a module.
Eric Moncada
Hi,
To get a clean code, I would like to add functions to the player object.
I do :
So I can call functions associated with player object :
What I would like is also to call functions that I write mySelf :
=> Where and how can I define "myFunction" ?
I know I can define this function in a module and pass the player object as parameter, but it would be cleaner if I can encapsulate all functions on the object.
Thanks for advice
Hi Eric,
Currently this method is not supported on the platform.
As you mentioned, you can define those functions in a module.
Thanks,
Oisin
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Not sure if that is possible Eric but the team will take a look.
Thanks.
Customer Support
Hi Eric,
Currently this method is not supported on the platform.
As you mentioned, you can define those functions in a module.
Thanks,
Oisin
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics