It would be better to have the transform and vector2 methods apply to the object itself, instead of returning a new instance.
Example:
//This is how it is today, it is way to verbose
var player1 = new Sprite({image: "player.png"});
var target = new Vector2({x: 100, y: 100});
player1.transform.position = player1.transform.position.add(player1.transform.position.lerp(player1.transform.position, target, Time.deltaTime));
Instead, we could rewrite the API to work like this:
var player1 = new Sprite({image: "player.png"});
var target = new Vector2({x: 100, y: 100});
player1.transform.position.lerp(target, Time.deltaTime);
This would seriously simplify things. So the functions, like add(), multiply(), lerp(), etc. would work directly on the object instance itself.
It would be better to have the transform and vector2 methods apply to the object itself, instead of returning a new instance.
Example:
Instead, we could rewrite the API to work like this:
This would seriously simplify things. So the functions, like add(), multiply(), lerp(), etc. would work directly on the object instance itself.