Stonekeeper Posted April 10, 2014 Share Posted April 10, 2014 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 More sharing options...
rich Posted April 11, 2014 Share Posted April 11, 2014 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 More sharing options...
Recommended Posts