Added final logo and start of CollisionMask

This commit is contained in:
Richard Davey 2013-05-19 14:01:11 +01:00
parent 53aa43566e
commit 05cc32fbc9
11 changed files with 243 additions and 8 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

View file

@ -135,6 +135,10 @@
<TypeScriptCompile Include="system\screens\BootScreen.ts" />
<TypeScriptCompile Include="system\input\MSPointer.ts" />
<TypeScriptCompile Include="system\input\Gestures.ts" />
<TypeScriptCompile Include="system\CollisionMask.ts" />
<Content Include="system\CollisionMask.js">
<DependentUpon>CollisionMask.ts</DependentUpon>
</Content>
<Content Include="system\input\Gestures.js">
<DependentUpon>Gestures.ts</DependentUpon>
</Content>

View file

@ -228,9 +228,10 @@ module Phaser {
}
/**
* Create a circle shape with specific diameter.
* @param diameter {number} Diameter of the circle.
* @return {GeomSprite} GeomSprite instance itself.
* Create a rectangle shape of the given width and height size
* @param width {Number} Width of the rectangle
* @param height {Number} Height of the rectangle
* @return {GeomSprite} GeomSprite instance.
*/
createRectangle(width: number, height: number): GeomSprite {

View file

@ -90,6 +90,30 @@ module Phaser {
}
/**
* Copies the x/y/width/height values from the source object into this Quad
* @method copyFrom
* @param {Any} source The source object to copy from. Can be a Quad, Rectangle or any object with exposed x/y/width/height properties
* @return {Quad} This object
**/
public copyFrom(source): Quad {
return this.setTo(source.x, source.y, source.width, source.height);
}
/**
* Copies the x/y/width/height values from this Quad into the given target object
* @method copyTo
* @param {Any} target The object to copy this quads values in to. Can be a Quad, Rectangle or any object with exposed x/y/width/height properties
* @return {Any} The target object
**/
public copyTo(target): any {
return target.copyFrom(this);
}
/**
* Returns a string representation of this object.
* @method toString

View file

@ -0,0 +1,157 @@
/// <reference path="../Game.ts" />
/**
* Phaser - CollisionMask
*/
module Phaser {
export class CollisionMask {
/**
* CollisionMask constructor. Creates a new <code>CollisionMask</code> for the given GameObject.
*
* @param game {Phaser.Game} Current game instance.
* @param parent {Phaser.GameObject} The GameObject this CollisionMask belongs to.
* @param x {number} The initial x position of the CollisionMask.
* @param y {number} The initial y position of the CollisionMask.
* @param width {number} The width of the CollisionMask.
* @param height {number} The height of the CollisionMask.
*/
constructor(game: Game, parent: GameObject, x: number, y: number, width: number, height: number) {
this._game = game;
this._parent = parent;
// By default the CollisionMask is a quad
this.type = CollisionMask.QUAD;
this.quad = new Phaser.Quad(this._parent.x, this._parent.y, this._parent.width, this._parent.height);
this.offset = new MicroPoint(0, 0);
return this;
}
private _game;
private _parent;
/**
* Geom type of this sprite. (available: UNASSIGNED, CIRCLE, LINE, POINT, RECTANGLE)
* @type {number}
*/
public type: number = 0;
/**
* Quad (a smaller version of Rectangle).
* @type {number}
*/
public static QUAD: number = 0;
/**
* Point.
* @type {number}
*/
public static POINT: number = 1;
/**
* Circle.
* @type {number}
*/
public static CIRCLE: number = 2;
/**
* Line.
* @type {number}
*/
public static LINE: number = 3;
/**
* Rectangle.
* @type {number}
*/
public static RECTANGLE: number = 4;
/**
* Polygon.
* @type {number}
*/
public static POLYGON: number = 5;
/**
* Rectangle shape container. A Rectangle instance.
* @type {Rectangle}
*/
public quad: Quad;
/**
* Point shape container. A Point instance.
* @type {Point}
*/
public point: Point;
/**
* Circle shape container. A Circle instance.
* @type {Circle}
*/
public circle: Circle;
/**
* Line shape container. A Line instance.
* @type {Line}
*/
public line: Line;
/**
* Rectangle shape container. A Rectangle instance.
* @type {Rectangle}
*/
public rect: Rectangle;
/**
* A value from the top-left of the GameObject frame that this collisionMask is offset to.
* If the CollisionMask is a Quad/Rectangle the offset relates to the top-left of that Quad.
* If the CollisionMask is a Circle the offset relates to the center of the circle.
* @type {MicroPoint}
*/
public offset: MicroPoint;
public update() {
}
/**
* Destroy all objects and references belonging to this CollisionMask
*/
public destroy() {
this._game = null;
this._parent = null;
this.quad = null;
this.point = null;
this.circle = null;
this.rect = null;
this.line = null;
this.offset = null;
}
}
}

View file

@ -80,6 +80,7 @@ V0.9.6
* Added Sprite.cacheKey which stores the key of the item from the cache that was used for its texture (if any)
* Added GameMath.shuffleArray
* Updated Animation.frame to return the index of the currentFrame if set
* Added Quad.copyTo and Quad.copyFrom
@ -88,6 +89,10 @@ V0.9.6
* TODO: Investigate bug re: tilemap collision and animation frames
* TODO: Update tests that use arrow keys and include touch/mouse support
* TODO: GameObject.clipRect
* TODO: Use CollisionMask in Input instead of Circle?
* TODO: Polygon geom primitive
* TODO: Move GameObject transforms to a single matrix
Requirements

View file

@ -25,8 +25,10 @@
}
xxx = (xx[i]) / (zz[i]);
yyy = (yy[i]) / (zz[i])--;
var x = xxx + myGame.input.x;
var y = yyy + myGame.input.y;
//var x: number = xxx + myGame.input.x;
//var y: number = yyy + myGame.input.y;
var x = xxx + 400;
var y = yyy + 300;
var c = '#ffffff';
if(zz[i] > 80) {
c = '#666666';
@ -35,7 +37,6 @@
} else if(zz[i] > 40) {
c = '#aaaaaa';
}
//else if (zz[i] > 20) c = '#ffffff';
starfield.setPixel(x, y, c);
}
}

17
build/phaser.d.ts vendored
View file

@ -1519,8 +1519,9 @@ module Phaser {
* @param frameRate {number} The speed in frames per second that the animation should play at (e.g. 60 fps).
* @param loop {boolean} Whether or not the animation is looped or just plays once.
* @param useNumericIndex {boolean} Use number indexes instead of string indexes?
* @return {Animation} The Animation that was created
*/
public add(name: string, frames?: any[], frameRate?: number, loop?: bool, useNumericIndex?: bool): void;
public add(name: string, frames?: any[], frameRate?: number, loop?: bool, useNumericIndex?: bool): Animation;
/**
* Check whether the frames is valid.
* @param frames {any[]} Frames to be validated.
@ -8688,6 +8689,20 @@ module Phaser {
public destroy(): void;
}
}
interface IPoint {
getDist(): number;
}
module Shapes {
class Point implements IPoint {
public x: number;
public y: number;
constructor(x: number, y: number);
public getDist(): number;
static origin: Point;
}
}
var p: IPoint;
var dist: number;
/**
* Phaser - State
*

View file

@ -1837,7 +1837,11 @@ var Phaser;
});
Object.defineProperty(Animation.prototype, "frame", {
get: function () {
return this._frameIndex;
if(this.currentFrame !== null) {
return this.currentFrame.index;
} else {
return this._frameIndex;
}
},
set: function (value) {
this.currentFrame = this._frameData.getFrame(value);
@ -2257,6 +2261,7 @@ var Phaser;
* @param frameRate {number} The speed in frames per second that the animation should play at (e.g. 60 fps).
* @param loop {boolean} Whether or not the animation is looped or just plays once.
* @param useNumericIndex {boolean} Use number indexes instead of string indexes?
* @return {Animation} The Animation that was created
*/
function (name, frames, frameRate, loop, useNumericIndex) {
if (typeof frames === "undefined") { frames = null; }
@ -2280,6 +2285,7 @@ var Phaser;
this._anims[name] = new Phaser.Animation(this._game, this._parent, this._frameData, name, frames, frameRate, loop);
this.currentAnim = this._anims[name];
this.currentFrame = this.currentAnim.currentFrame;
return this._anims[name];
};
AnimationManager.prototype.validateFrames = /**
* Check whether the frames is valid.
@ -15035,6 +15041,28 @@ var Phaser;
})();
Phaser.FXManager = FXManager;
})(Phaser || (Phaser = {}));
// Module
var Shapes;
(function (Shapes) {
// Class
var Point = (function () {
// Constructor
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.getDist = // Instance member
function () {
return Math.sqrt(this.x * this.x + this.y * this.y);
};
Point.origin = new Point(0, 0);
return Point;
})();
Shapes.Point = Point;
})(Shapes || (Shapes = {}));
// Local variables
var p = new Shapes.Point(3, 4);
var dist = p.getDist();
/// <reference path="Game.ts" />
/**
* Phaser - State