Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Using callbacks to update sprite variables


Stonekeeper
 Share

Recommended Posts

Are there any plans for adding getters and setters to the objects? I'm currently doing some stuff where I want to change a variable via a callback mechanism, but I don't want to just set variables as that effectively means writing setters for every one, EG:

function setRotation(value) {   ship.rotation = value;}var r = someFunctionThatTakesACallback(x,y,z,setRotation);

I'm thinking of creating an ugly, ugly hack in the form of a generic "_setValue(object, varname, value)" function, via extending the prototype, but I don't want to go to that hassle if there's something better in the works ( and using eval or a 'string split/iterate over the objects' approach is plain wrong ).

 

Thanks.

Link to comment
Share on other sites

You mean having like a property bucket? So you'd do object.setProperty('key', true); or similar?

 

There's no plan for this right now, but we may do. I would just extend Sprite, add the getter/setter in that you need and just use those instead? That would be the cleanest way of doing it, rather than adding on variables to an existing object at run-time, which invalidates the VMs internal class structures, causing performance drops.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...