Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Sprite(img)
- {
- this.img = img;
- this.rot = 0;
- this.scl = createVector(1, 1);
- this.pos = createVector(0, 0);
- this.cnt = createVector(0, 0);
- this.clp = {pos: createVector(0, 0), size: createVector(1, 1)};
- this.col = color(255);
- this.draw = function()
- {
- var w = this.img.width * this.clp.size.x;
- var h = this.img.height * this.clp.size.y;
- // Makes sure rotation and scaling happen around
- // the correct axis of the sprite.
- push();
- translate(this.pos.x, this.pos.y);
- rotate (this.rot);
- scale (this.scl.x, this.scl.y);
- translate(w * -this.cnt.x, h * -this.cnt.y);
- if (this.col != color(255))
- tint(this.col);
- image
- (
- this.img,
- this.img.width * this.clp.pos.x,
- this.img.height * this.clp.pos.y,
- w,
- h,
- 0,
- 0,
- w,
- h
- );
- pop();
- //if (this.col != color(255))
- // noTint();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement