Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change API #18

Open
thomas-alrek opened this issue Sep 16, 2016 · 0 comments
Open

Change API #18

thomas-alrek opened this issue Sep 16, 2016 · 0 comments

Comments

@thomas-alrek
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant