mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
Merge branch 'dev' of https://github.com/photonstorm/phaser into dev
This commit is contained in:
commit
2f3fc22b50
8 changed files with 93 additions and 48 deletions
|
@ -138,6 +138,11 @@ Phaser.AnimationParser = {
|
|||
frames[i].spriteSourceSize.h
|
||||
);
|
||||
}
|
||||
|
||||
if (frames[i].rotated)
|
||||
{
|
||||
newFrame.rotated = true;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
|
@ -251,6 +256,11 @@ Phaser.AnimationParser = {
|
|||
);
|
||||
}
|
||||
|
||||
if (frames[key].rotated)
|
||||
{
|
||||
newFrame.rotated = true;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ Phaser.Frame = function (index, x, y, width, height, name) {
|
|||
this.distance = Phaser.Math.distance(0, 0, width, height);
|
||||
|
||||
/**
|
||||
* @property {boolean} rotated - Rotated? (not yet implemented)
|
||||
* @property {boolean} rotated - Is the frame rotated in the source texture?
|
||||
* @default
|
||||
*/
|
||||
this.rotated = false;
|
||||
|
|
|
@ -190,6 +190,11 @@ Phaser.Component.LoadTexture.prototype = {
|
|||
this.texture.trim = null;
|
||||
}
|
||||
|
||||
if (frame.rotated)
|
||||
{
|
||||
this.texture.rotated = true;
|
||||
}
|
||||
|
||||
if (this.cropRect)
|
||||
{
|
||||
this.updateCrop();
|
||||
|
|
|
@ -448,62 +448,86 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession, matrix)
|
|||
}
|
||||
|
||||
// Ignore null sources
|
||||
if (this.texture.valid)
|
||||
if (!this.texture.valid)
|
||||
{
|
||||
var resolution = this.texture.baseTexture.resolution / renderSession.resolution;
|
||||
|
||||
renderSession.context.globalAlpha = this.worldAlpha;
|
||||
|
||||
// If smoothingEnabled is supported and we need to change the smoothing property for this texture
|
||||
if (renderSession.smoothProperty && renderSession.scaleMode !== this.texture.baseTexture.scaleMode)
|
||||
// Update the children and leave
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
renderSession.scaleMode = this.texture.baseTexture.scaleMode;
|
||||
renderSession.context[renderSession.smoothProperty] = (renderSession.scaleMode === PIXI.scaleModes.LINEAR);
|
||||
this.children[i]._renderCanvas(renderSession);
|
||||
}
|
||||
|
||||
// If the texture is trimmed we offset by the trim x/y, otherwise we use the frame dimensions
|
||||
var dx = (this.texture.trim) ? this.texture.trim.x - this.anchor.x * this.texture.trim.width : this.anchor.x * -this.texture.frame.width;
|
||||
var dy = (this.texture.trim) ? this.texture.trim.y - this.anchor.y * this.texture.trim.height : this.anchor.y * -this.texture.frame.height;
|
||||
|
||||
var tx = (wt.tx * renderSession.resolution) + renderSession.shakeX;
|
||||
var ty = (wt.ty * renderSession.resolution) + renderSession.shakeY;
|
||||
|
||||
// Allow for pixel rounding
|
||||
if (renderSession.roundPixels)
|
||||
if (this._mask)
|
||||
{
|
||||
renderSession.context.setTransform(wt.a, wt.b, wt.c, wt.d, tx | 0, ty | 0);
|
||||
dx |= 0;
|
||||
dy |= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
renderSession.context.setTransform(wt.a, wt.b, wt.c, wt.d, tx, ty);
|
||||
renderSession.maskManager.popMask(renderSession);
|
||||
}
|
||||
|
||||
var cw = this.texture.crop.width;
|
||||
var ch = this.texture.crop.height;
|
||||
return;
|
||||
}
|
||||
|
||||
dx /= resolution;
|
||||
dy /= resolution;
|
||||
var resolution = this.texture.baseTexture.resolution / renderSession.resolution;
|
||||
|
||||
if (this.tint !== 0xFFFFFF)
|
||||
renderSession.context.globalAlpha = this.worldAlpha;
|
||||
|
||||
// If smoothingEnabled is supported and we need to change the smoothing property for this texture
|
||||
if (renderSession.smoothProperty && renderSession.scaleMode !== this.texture.baseTexture.scaleMode)
|
||||
{
|
||||
renderSession.scaleMode = this.texture.baseTexture.scaleMode;
|
||||
renderSession.context[renderSession.smoothProperty] = (renderSession.scaleMode === PIXI.scaleModes.LINEAR);
|
||||
}
|
||||
|
||||
// If the texture is trimmed we offset by the trim x/y, otherwise we use the frame dimensions
|
||||
var dx = (this.texture.trim) ? this.texture.trim.x - this.anchor.x * this.texture.trim.width : this.anchor.x * -this.texture.frame.width;
|
||||
var dy = (this.texture.trim) ? this.texture.trim.y - this.anchor.y * this.texture.trim.height : this.anchor.y * -this.texture.frame.height;
|
||||
|
||||
var tx = (wt.tx * renderSession.resolution) + renderSession.shakeX;
|
||||
var ty = (wt.ty * renderSession.resolution) + renderSession.shakeY;
|
||||
|
||||
// Allow for pixel rounding
|
||||
if (renderSession.roundPixels)
|
||||
{
|
||||
renderSession.context.setTransform(wt.a, wt.b, wt.c, wt.d, tx | 0, ty | 0);
|
||||
dx |= 0;
|
||||
dy |= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
renderSession.context.setTransform(wt.a, wt.b, wt.c, wt.d, tx, ty);
|
||||
}
|
||||
|
||||
var cw = this.texture.crop.width;
|
||||
var ch = this.texture.crop.height;
|
||||
|
||||
if (this.texture.rotated)
|
||||
{
|
||||
// 90 degree coordinate rotation
|
||||
cw = ch;
|
||||
ch = this.texture.crop.width;
|
||||
|
||||
renderSession.context.translate(0, cw);
|
||||
renderSession.context.rotate(-1.5707963267948966);
|
||||
}
|
||||
|
||||
dx /= resolution;
|
||||
dy /= resolution;
|
||||
|
||||
if (this.tint !== 0xFFFFFF)
|
||||
{
|
||||
if (this.texture.requiresReTint || this.cachedTint !== this.tint)
|
||||
{
|
||||
if (this.texture.requiresReTint || this.cachedTint !== this.tint)
|
||||
{
|
||||
this.tintedTexture = PIXI.CanvasTinter.getTintedTexture(this, this.tint);
|
||||
this.tintedTexture = PIXI.CanvasTinter.getTintedTexture(this, this.tint);
|
||||
|
||||
this.cachedTint = this.tint;
|
||||
this.texture.requiresReTint = false;
|
||||
}
|
||||
this.cachedTint = this.tint;
|
||||
this.texture.requiresReTint = false;
|
||||
}
|
||||
|
||||
renderSession.context.drawImage(this.tintedTexture, 0, 0, cw, ch, dx, dy, cw / resolution, ch / resolution);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cx = this.texture.crop.x;
|
||||
var cy = this.texture.crop.y;
|
||||
renderSession.context.drawImage(this.texture.baseTexture.source, cx, cy, cw, ch, dx, dy, cw / resolution, ch / resolution);
|
||||
}
|
||||
renderSession.context.drawImage(this.tintedTexture, 0, 0, cw, ch, dx, dy, cw / resolution, ch / resolution);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cx = this.texture.crop.x;
|
||||
var cy = this.texture.crop.y;
|
||||
|
||||
renderSession.context.drawImage(this.texture.baseTexture.source, cx, cy, cw, ch, dx, dy, cw / resolution, ch / resolution);
|
||||
}
|
||||
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
|
|
|
@ -328,13 +328,13 @@ PIXI.WebGLRenderer.prototype.setTexturePriority = function (textureNameCollectio
|
|||
if (index + 1 < maxTextures)
|
||||
{
|
||||
imageCache[imageName].base.textureIndex = index + 1;
|
||||
|
||||
this.currentBatchedTextures.push(imageName);
|
||||
}
|
||||
else
|
||||
{
|
||||
imageCache[imageName].base.textureIndex = maxTextures - 1;
|
||||
}
|
||||
|
||||
this.currentBatchedTextures.push(imageName);
|
||||
}
|
||||
|
||||
return this.currentBatchedTextures;
|
||||
|
|
|
@ -134,6 +134,8 @@ PIXI.Texture = function(baseTexture, frame, crop, trim)
|
|||
*/
|
||||
this.crop = crop || new PIXI.Rectangle(0, 0, 1, 1);
|
||||
|
||||
this.rotated = false;
|
||||
|
||||
if (baseTexture.hasLoaded)
|
||||
{
|
||||
if (this.noFrame) frame = new PIXI.Rectangle(0, 0, baseTexture.width, baseTexture.height);
|
||||
|
|
4
typescript/phaser.d.ts
vendored
4
typescript/phaser.d.ts
vendored
|
@ -1,7 +1,7 @@
|
|||
/// <reference path="pixi.d.ts" />
|
||||
/// <reference path="p2.d.ts" />
|
||||
|
||||
// Type definitions for Phaser 3.0.0 - 7th September 2016
|
||||
// Type definitions for Phaser 3.0.0
|
||||
// Project: https://github.com/photonstorm/phaser
|
||||
|
||||
declare module "phaser" {
|
||||
|
@ -18,6 +18,7 @@ declare class Phaser {
|
|||
static CANVAS: number;
|
||||
static WEBGL: number;
|
||||
static HEADLESS: number;
|
||||
static WEBGL_MULTI: number;
|
||||
|
||||
static BITMAPDATA: number;
|
||||
static BITMAPTEXT: number;
|
||||
|
@ -1402,6 +1403,7 @@ declare module Phaser {
|
|||
seed?: string;
|
||||
state?: Phaser.State;
|
||||
forceSetTimeOut: boolean;
|
||||
multiTextue: boolean;
|
||||
|
||||
}
|
||||
|
||||
|
|
2
typescript/pixi.d.ts
vendored
2
typescript/pixi.d.ts
vendored
|
@ -1300,6 +1300,7 @@ declare module PIXI {
|
|||
clearBeforeRender: boolean;
|
||||
width: number;
|
||||
height: number;
|
||||
currentBatchedTextures: string[];
|
||||
view: HTMLCanvasElement;
|
||||
projection: Point;
|
||||
offset: Point;
|
||||
|
@ -1318,6 +1319,7 @@ declare module PIXI {
|
|||
updateTexture(texture: Texture): void;
|
||||
destroy(): void;
|
||||
mapBlendModes(): void;
|
||||
setTexturePriority(textureNameCollection: string[]): string[];
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue