Skip to content

Commit a993277

Browse files
authored
Merge pull request phaserjs#4773 from rexrainbow/bob-tint
Add tint feature of bob
2 parents 487ec88 + 8a9e74f commit a993277

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

src/gameobjects/blitter/BlitterWebGLRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ var BlitterWebGLRenderer = function (renderer, src, interpolationPercentage, cam
9494
var tx1 = calcMatrix.getX(xw, yh);
9595
var ty1 = calcMatrix.getY(xw, yh);
9696

97-
var tint = Utils.getTintAppendFloatAlpha(0xffffff, bobAlpha);
97+
var tint = Utils.getTintAppendFloatAlpha(bob.tint, bobAlpha);
9898

9999
// Bind texture only if the Texture Source is different from before
100100
if (frame.sourceIndex !== prevTextureSourceIndex)

src/gameobjects/blitter/Bob.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ var Bob = new Class({
8888
*/
8989
this.data = {};
9090

91+
/**
92+
* The tint value of this Bob.
93+
*
94+
* @name Phaser.GameObjects.Bob#tint
95+
* @type {number}
96+
* @default 0xffffff
97+
* @since 3.20.0
98+
*/
99+
this.tint = 0xffffff;
100+
91101
/**
92102
* The visible state of this Bob.
93103
*
@@ -215,6 +225,25 @@ var Bob = new Class({
215225
return this;
216226
},
217227

228+
/**
229+
* Changes the position of this Bob to the values given.
230+
*
231+
* @method Phaser.GameObjects.Bob#setPosition
232+
* @since 3.20.0
233+
*
234+
* @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object.
235+
* @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object.
236+
*
237+
* @return {Phaser.GameObjects.Bob} This Bob Game Object.
238+
*/
239+
setPosition: function (x, y)
240+
{
241+
this.x = x;
242+
this.y = y;
243+
244+
return this;
245+
},
246+
218247
/**
219248
* Sets the horizontal flipped state of this Bob.
220249
*
@@ -307,6 +336,23 @@ var Bob = new Class({
307336
return this;
308337
},
309338

339+
/**
340+
* Sets the tint of this Bob.
341+
*
342+
* @method Phaser.GameObjects.Bob#setTint
343+
* @since 3.20.0
344+
*
345+
* @param {number} value - The tint value used for this Bob. Between 0 and 0xffffff.
346+
*
347+
* @return {Phaser.GameObjects.Bob} This Bob Game Object.
348+
*/
349+
setTint: function (value)
350+
{
351+
this.tint = value;
352+
353+
return this;
354+
},
355+
310356
/**
311357
* Destroys this Bob instance.
312358
* Removes itself from the Blitter and clears the parent, frame and data properties.

0 commit comments

Comments
 (0)