Sign In Register

How can we help you today?

Start a new topic
Answered

Player object functions best practice

Hi,


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

Hi Eric,


Currently this method is not supported on the platform.

As you mentioned, you can define those functions in a module.


Thanks,


Oisin






Not sure if that is possible Eric but the team will take a look.


Thanks.

Answer

Hi Eric,


Currently this method is not supported on the platform.

As you mentioned, you can define those functions in a module.


Thanks,


Oisin





Login to post a comment