mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
Preparing new tests
This commit is contained in:
parent
3c0c349089
commit
09f57fa346
237 changed files with 13385 additions and 34447 deletions
|
@ -92,6 +92,10 @@
|
|||
<DependentUpon>Game.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="gameobjects\Sprite.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\IGameObject.ts" />
|
||||
<Content Include="gameobjects\IGameObject.js">
|
||||
<DependentUpon>IGameObject.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="math\GameMath.js">
|
||||
<DependentUpon>GameMath.ts</DependentUpon>
|
||||
</Content>
|
||||
|
@ -99,14 +103,9 @@
|
|||
<Content Include="gameobjects\GameObjectFactory.js">
|
||||
<DependentUpon>GameObjectFactory.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="components\ScrollRegion.ts" />
|
||||
<Content Include="components\ScrollRegion.js">
|
||||
<DependentUpon>ScrollRegion.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\Sprite.js">
|
||||
<DependentUpon>Sprite.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geom\Polygon.ts" />
|
||||
<TypeScriptCompile Include="utils\PointUtils.ts" />
|
||||
<TypeScriptCompile Include="utils\CircleUtils.ts" />
|
||||
<TypeScriptCompile Include="renderers\CanvasRenderer.ts" />
|
||||
|
@ -131,24 +130,17 @@
|
|||
<Content Include="utils\PointUtils.js">
|
||||
<DependentUpon>PointUtils.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\Polygon.js">
|
||||
<DependentUpon>Polygon.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geom\Response.ts" />
|
||||
<TypeScriptCompile Include="utils\RectangleUtils.ts" />
|
||||
<Content Include="utils\RectangleUtils.js">
|
||||
<DependentUpon>RectangleUtils.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\Response.js">
|
||||
<DependentUpon>Response.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="core\Circle.js">
|
||||
<DependentUpon>Circle.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\IntersectResult.js">
|
||||
<Content Include="math\IntersectResult.js">
|
||||
<DependentUpon>IntersectResult.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\Line.js">
|
||||
<Content Include="core\Line.js">
|
||||
<DependentUpon>Line.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="math\Vec2Utils.ts" />
|
||||
|
@ -216,18 +208,10 @@
|
|||
<Content Include="system\StageScaleMode.js">
|
||||
<DependentUpon>StageScaleMode.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="components\Tile.js">
|
||||
<DependentUpon>Tile.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="components\TilemapLayer.ts" />
|
||||
<Content Include="components\TilemapLayer.js">
|
||||
<DependentUpon>TilemapLayer.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="tweens\Tween.js">
|
||||
<DependentUpon>Tween.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="tweens\Tween.ts" />
|
||||
<TypeScriptCompile Include="components\Tile.ts" />
|
||||
<TypeScriptCompile Include="system\StageScaleMode.ts" />
|
||||
<TypeScriptCompile Include="system\RequestAnimationFrame.ts" />
|
||||
<TypeScriptCompile Include="math\RandomDataGenerator.ts" />
|
||||
|
@ -299,8 +283,8 @@
|
|||
<TypeScriptCompile Include="components\animation\Frame.ts" />
|
||||
<TypeScriptCompile Include="loader\AnimationLoader.ts" />
|
||||
<TypeScriptCompile Include="components\animation\Animation.ts" />
|
||||
<TypeScriptCompile Include="geom\Line.ts" />
|
||||
<TypeScriptCompile Include="geom\IntersectResult.ts" />
|
||||
<TypeScriptCompile Include="core\Line.ts" />
|
||||
<TypeScriptCompile Include="math\IntersectResult.ts" />
|
||||
<TypeScriptCompile Include="core\Circle.ts" />
|
||||
<Content Include="core\Group.js">
|
||||
<DependentUpon>Group.ts</DependentUpon>
|
||||
|
|
|
@ -21,11 +21,11 @@ module Phaser {
|
|||
this.add = game.add;
|
||||
this.camera = game.camera;
|
||||
this.cache = game.cache;
|
||||
this.collision = game.collision;
|
||||
//this.collision = game.collision;
|
||||
this.input = game.input;
|
||||
this.loader = game.loader;
|
||||
this.math = game.math;
|
||||
this.motion = game.motion;
|
||||
//this.motion = game.motion;
|
||||
this.sound = game.sound;
|
||||
this.stage = game.stage;
|
||||
this.time = game.time;
|
||||
|
@ -55,7 +55,7 @@ module Phaser {
|
|||
* Reference to the collision helper.
|
||||
* @type {Collision}
|
||||
*/
|
||||
public collision: Collision;
|
||||
//public collision: Collision;
|
||||
|
||||
/**
|
||||
* Reference to the GameObject Factory.
|
||||
|
@ -85,7 +85,7 @@ module Phaser {
|
|||
* Reference to the motion helper.
|
||||
* @type {Motion}
|
||||
*/
|
||||
public motion: Motion;
|
||||
//public motion: Motion;
|
||||
|
||||
/**
|
||||
* Reference to the sound manager.
|
||||
|
@ -161,9 +161,9 @@ module Phaser {
|
|||
* @param context The context in which the callbacks will be called
|
||||
* @returns {boolean} true if the objects overlap, otherwise false.
|
||||
*/
|
||||
public collide(objectOrGroup1 = null, objectOrGroup2 = null, notifyCallback = null, context? = this.game.callbackContext): bool {
|
||||
return this.collision.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, Collision.separate, context);
|
||||
}
|
||||
//public collide(objectOrGroup1 = null, objectOrGroup2 = null, notifyCallback = null, context? = this.game.callbackContext): bool {
|
||||
// return this.collision.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, Collision.separate, context);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../gameobjects/Tilemap.ts" />
|
||||
/// <reference path="../gameobjects/IGameObject.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - TilemapLayer
|
||||
|
@ -354,7 +356,7 @@ module Phaser {
|
|||
* @param object {GameObject} Tiles you want to get that overlaps this.
|
||||
* @return {array} Array with tiles informations. (Each contains x, y and the tile.)
|
||||
*/
|
||||
public getTileOverlaps(object: GameObject) {
|
||||
public getTileOverlaps(object: IGameObject) {
|
||||
|
||||
// If the object is outside of the world coordinates then abort the check (tilemap has to exist within world bounds)
|
||||
if (object.collisionMask.x < 0 || object.collisionMask.x > this.widthInPixels || object.collisionMask.y < 0 || object.collisionMask.bottom > this.heightInPixels)
|
||||
|
|
|
@ -14,6 +14,7 @@ module Phaser.Components {
|
|||
|
||||
constructor(parent: Sprite, key?: string = '', canvas?: HTMLCanvasElement = null, context?: CanvasRenderingContext2D = null) {
|
||||
|
||||
this._game = parent.game;
|
||||
this._sprite = parent;
|
||||
|
||||
this.canvas = canvas;
|
||||
|
@ -30,6 +31,11 @@ module Phaser.Components {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private _game: Game;
|
||||
|
||||
/**
|
||||
* Reference to the Image stored in the Game.Cache that is used as the texture for the Sprite.
|
||||
*/
|
||||
|
@ -121,8 +127,32 @@ module Phaser.Components {
|
|||
* @param clearAnimations {boolean} If this Sprite has a set of animation data already loaded you can choose to keep or clear it with this boolean
|
||||
* @return {Sprite} Sprite instance itself.
|
||||
*/
|
||||
public loadImage(key: string, clearAnimations: bool = true): Sprite {
|
||||
return Phaser.SpriteUtils.loadTexture(this._sprite, key, clearAnimations);
|
||||
public loadImage(key: string, clearAnimations: bool = true) {
|
||||
|
||||
//if (clearAnimations && sprite.animations.frameData !== null)
|
||||
//{
|
||||
// sprite.animations.destroy();
|
||||
//}
|
||||
|
||||
if (this._game.cache.getImage(key) !== null)
|
||||
{
|
||||
this.setTo(this._game.cache.getImage(key), null);
|
||||
|
||||
if (this._game.cache.isSpriteSheet(key))
|
||||
{
|
||||
//sprite.animations.loadFrameData(sprite._game.cache.getFrameData(key));
|
||||
//sprite.collisionMask.width = sprite.animations.currentFrame.width;
|
||||
//sprite.collisionMask.height = sprite.animations.currentFrame.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._sprite.frameBounds.width = this.width;
|
||||
this._sprite.frameBounds.height = this.height;
|
||||
//sprite.collisionMask.width = sprite._texture.width;
|
||||
//sprite.collisionMask.height = sprite._texture.height;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,8 +160,17 @@ module Phaser.Components {
|
|||
* @param texture {DynamicTexture} The texture object to be used by this sprite.
|
||||
* @return {Sprite} Sprite instance itself.
|
||||
*/
|
||||
public loadDynamicTexture(texture: DynamicTexture): Sprite {
|
||||
return Phaser.SpriteUtils.loadDynamicTexture(this._sprite, texture);
|
||||
public loadDynamicTexture(texture: DynamicTexture) {
|
||||
|
||||
//if (sprite.animations.frameData !== null)
|
||||
//{
|
||||
// sprite.animations.destroy();
|
||||
//}
|
||||
|
||||
this.setTo(null, texture);
|
||||
this._sprite.frameBounds.width = this.width;
|
||||
this._sprite.frameBounds.height = this.height;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../utils/RectangleUtils.ts" />
|
||||
/// <reference path="IGameObject.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - DynamicTexture
|
||||
|
@ -234,7 +236,7 @@ module Phaser {
|
|||
public copyPixels(sourceTexture: DynamicTexture, sourceRect: Rectangle, destPoint: Point) {
|
||||
|
||||
// Swap for drawImage if the sourceRect is the same size as the sourceTexture to avoid a costly getImageData call
|
||||
if (sourceRect.equals(this.bounds) == true)
|
||||
if (Phaser.RectangleUtils.equals(sourceRect, this.bounds) == true)
|
||||
{
|
||||
this.context.drawImage(sourceTexture.canvas, destPoint.x, destPoint.y);
|
||||
}
|
||||
|
@ -246,15 +248,15 @@ module Phaser {
|
|||
}
|
||||
|
||||
/**
|
||||
* Given an array of GameObjects it will update each of them so that their canvas/contexts reference this DynamicTexture
|
||||
* Given an array of Sprites it will update each of them so that their canvas/contexts reference this DynamicTexture
|
||||
* @param objects {Array} An array of GameObjects, or objects that inherit from it such as Sprites
|
||||
*/
|
||||
public assignCanvasToGameObjects(objects: GameObject[]) {
|
||||
public assignCanvasToGameObjects(objects: IGameObject[]) {
|
||||
|
||||
for (var i = 0; i < objects.length; i++)
|
||||
{
|
||||
objects[i].canvas = this.canvas;
|
||||
objects[i].context = this.context;
|
||||
objects[i].texture.canvas = this.canvas;
|
||||
objects[i].texture.context = this.context;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -275,9 +277,7 @@ module Phaser {
|
|||
* @param y {number} The Y coordinate to render on the stage to (given in screen coordinates, not world)
|
||||
*/
|
||||
public render(x?: number = 0, y?: number = 0) {
|
||||
|
||||
this.game.stage.context.drawImage(this.canvas, x, y);
|
||||
|
||||
}
|
||||
|
||||
public get width(): number {
|
||||
|
|
|
@ -135,9 +135,9 @@ module Phaser {
|
|||
* @param [tileHeight] {number} height of each tile.
|
||||
* @return {Tilemap} The newly created tilemap object.
|
||||
*/
|
||||
public tilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap {
|
||||
return <Tilemap> this._world.group.add(new Tilemap(this._game, key, mapData, format, resizeWorld, tileWidth, tileHeight));
|
||||
}
|
||||
//public tilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap {
|
||||
// return <Tilemap> this._world.group.add(new Tilemap(this._game, key, mapData, format, resizeWorld, tileWidth, tileHeight));
|
||||
//}
|
||||
|
||||
/**
|
||||
* Create a tween object for a specific object.
|
||||
|
@ -200,9 +200,9 @@ module Phaser {
|
|||
* @param tilemap The Tilemap to add to the Game World
|
||||
* @return {Phaser.Tilemap} The Tilemap object
|
||||
*/
|
||||
public existingTilemap(tilemap: Tilemap): Tilemap {
|
||||
return this._world.group.add(tilemap);
|
||||
}
|
||||
//public existingTilemap(tilemap: Tilemap): Tilemap {
|
||||
// return this._world.group.add(tilemap);
|
||||
//}
|
||||
|
||||
/**
|
||||
* Add an existing Tween to the current world.
|
||||
|
|
59
Phaser/gameobjects/IGameObject.ts
Normal file
59
Phaser/gameobjects/IGameObject.ts
Normal file
|
@ -0,0 +1,59 @@
|
|||
/// <reference path="../Game.ts" />
|
||||
|
||||
module Phaser {
|
||||
|
||||
export interface IGameObject {
|
||||
|
||||
/**
|
||||
* Reference to the main game object
|
||||
*/
|
||||
game: Game;
|
||||
|
||||
/**
|
||||
* The type of game object.
|
||||
*/
|
||||
type: number;
|
||||
|
||||
/**
|
||||
* Reference to the Renderer.renderSprite method. Can be overriden by custom classes.
|
||||
*/
|
||||
render;
|
||||
|
||||
/**
|
||||
* Controls if both <code>update</code> and render are called by the core game loop.
|
||||
*/
|
||||
exists: bool;
|
||||
|
||||
/**
|
||||
* Controls if <code>update()</code> is automatically called by the core game loop.
|
||||
*/
|
||||
active: bool;
|
||||
|
||||
/**
|
||||
* Controls if this Sprite is rendered or skipped during the core game loop.
|
||||
*/
|
||||
visible: bool;
|
||||
|
||||
/**
|
||||
* The position of the Sprite in world and screen coordinates.
|
||||
*/
|
||||
position: Phaser.Components.Position;
|
||||
|
||||
/**
|
||||
* The texture used to render the Sprite.
|
||||
*/
|
||||
texture: Phaser.Components.Texture;
|
||||
|
||||
/**
|
||||
* Scale of the Sprite. A scale of 1.0 is the original size. 0.5 half size. 2.0 double sized.
|
||||
*/
|
||||
scale: Phaser.Vec2;
|
||||
|
||||
/**
|
||||
* The influence of camera movement upon the Sprite.
|
||||
*/
|
||||
scrollFactor: Phaser.Vec2;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
module Phaser {
|
||||
|
||||
export class Sprite {
|
||||
export class Sprite implements IGameObject {
|
||||
|
||||
/**
|
||||
* Create a new <code>Sprite</code>.
|
||||
|
@ -34,12 +34,18 @@ module Phaser {
|
|||
this.visible = true;
|
||||
this.alive = true;
|
||||
|
||||
this.frameBounds = new Rectangle(x, y, width, height);
|
||||
this.origin = new Phaser.Vec2(0, 0);
|
||||
this.scrollFactor = new Phaser.Vec2(1, 1);
|
||||
this.scale = new Phaser.Vec2(1, 1);
|
||||
|
||||
this.position = new Phaser.Components.Position(this, x, y);
|
||||
this.texture = new Phaser.Components.Texture(this, key, game.stage.canvas, game.stage.context);
|
||||
|
||||
this.width = this.frameBounds.width;
|
||||
this.height = this.frameBounds.height;
|
||||
this.rotation = this.position.rotation;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,6 +83,10 @@ module Phaser {
|
|||
*/
|
||||
public alive: bool;
|
||||
|
||||
// Getters only, don't over-write these values
|
||||
public width: number;
|
||||
public height: number;
|
||||
|
||||
/**
|
||||
* The position of the Sprite in world and screen coordinates.
|
||||
*/
|
||||
|
@ -94,9 +104,102 @@ module Phaser {
|
|||
*/
|
||||
public frameBounds: Phaser.Rectangle;
|
||||
|
||||
/**
|
||||
* Scale of the Sprite. A scale of 1.0 is the original size. 0.5 half size. 2.0 double sized.
|
||||
*/
|
||||
public scale: Phaser.Vec2;
|
||||
|
||||
/**
|
||||
* The influence of camera movement upon the Sprite.
|
||||
*/
|
||||
public scrollFactor: Phaser.Vec2;
|
||||
|
||||
/**
|
||||
* The Sprite origin is the point around which scale and rotation transforms take place.
|
||||
*/
|
||||
public origin: Phaser.Vec2;
|
||||
|
||||
/**
|
||||
* Pre-update is called right before update() on each object in the game loop.
|
||||
*/
|
||||
public preUpdate() {
|
||||
|
||||
//this.last.x = this.frameBounds.x;
|
||||
//this.last.y = this.frameBounds.y;
|
||||
|
||||
//this.collisionMask.preUpdate();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this function to update your class's position and appearance.
|
||||
*/
|
||||
public update() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically called after update() by the game loop.
|
||||
*/
|
||||
public postUpdate() {
|
||||
|
||||
/*
|
||||
this.animations.update();
|
||||
|
||||
if (this.moves)
|
||||
{
|
||||
this.updateMotion();
|
||||
}
|
||||
|
||||
if (this.worldBounds != null)
|
||||
{
|
||||
if (this.outOfBoundsAction == GameObject.OUT_OF_BOUNDS_KILL)
|
||||
{
|
||||
if (this.x < this.worldBounds.x || this.x > this.worldBounds.right || this.y < this.worldBounds.y || this.y > this.worldBounds.bottom)
|
||||
{
|
||||
this.kill();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.x < this.worldBounds.x)
|
||||
{
|
||||
this.x = this.worldBounds.x;
|
||||
}
|
||||
else if (this.x > this.worldBounds.right)
|
||||
{
|
||||
this.x = this.worldBounds.right;
|
||||
}
|
||||
|
||||
if (this.y < this.worldBounds.y)
|
||||
{
|
||||
this.y = this.worldBounds.y;
|
||||
}
|
||||
else if (this.y > this.worldBounds.bottom)
|
||||
{
|
||||
this.y = this.worldBounds.bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.collisionMask.update();
|
||||
|
||||
if (this.inputEnabled)
|
||||
{
|
||||
this.updateInput();
|
||||
}
|
||||
|
||||
this.wasTouching = this.touching;
|
||||
this.touching = Collision.NONE;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up memory.
|
||||
*/
|
||||
public destroy() {
|
||||
}
|
||||
|
||||
/**
|
||||
* x value of the object.
|
||||
*/
|
||||
|
@ -130,6 +233,17 @@ module Phaser {
|
|||
this.position.z = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* rotation value of the object.
|
||||
*/
|
||||
public get rotation(): number {
|
||||
return this.position.rotation;
|
||||
}
|
||||
|
||||
public set rotation(value: number) {
|
||||
this.position.rotation = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Polygon
|
||||
*
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Polygon {
|
||||
|
||||
/**
|
||||
* A *convex* clockwise polygon
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param {Vec2} pos A vector representing the origin of the polygon (all other points are relative to this one)
|
||||
* @param {Array.<Vec2>} points An Array of vectors representing the points in the polygon, in clockwise order.
|
||||
**/
|
||||
constructor(pos?: Vec2 = new Vec2, points?: Vec2[] = [], parent?:any = null) {
|
||||
|
||||
this.pos = pos;
|
||||
this.points = points;
|
||||
this.parent = parent;
|
||||
this.recalc();
|
||||
|
||||
}
|
||||
|
||||
public parent: any;
|
||||
public pos: Vec2;
|
||||
public points: Vec2[];
|
||||
public edges: Vec2[];
|
||||
public normals: Vec2[];
|
||||
|
||||
/**
|
||||
* Recalculate the edges and normals of the polygon. This
|
||||
* MUST be called if the points array is modified at all and
|
||||
* the edges or normals are to be accessed.
|
||||
*/
|
||||
public recalc() {
|
||||
|
||||
var points = this.points;
|
||||
var len = points.length;
|
||||
|
||||
this.edges = [];
|
||||
this.normals = [];
|
||||
|
||||
for (var i = 0; i < len; i++)
|
||||
{
|
||||
var p1 = points[i];
|
||||
var p2 = i < len - 1 ? points[i + 1] : points[0];
|
||||
var e = new Vec2().copyFrom(p2).sub(p1);
|
||||
var n = new Vec2().copyFrom(e).perp().normalize();
|
||||
this.edges.push(e);
|
||||
this.normals.push(n);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="Polygon.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Response
|
||||
*
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Response {
|
||||
|
||||
/**
|
||||
* An object representing the result of an intersection. Contain information about:
|
||||
* - The two objects participating in the intersection
|
||||
* - The vector representing the minimum change necessary to extract the first object
|
||||
* from the second one.
|
||||
* - Whether the first object is entirely inside the second, or vice versa.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
constructor() {
|
||||
|
||||
this.a = null;
|
||||
this.b = null;
|
||||
this.overlapN = new Vec2;
|
||||
this.overlapV = new Vec2;
|
||||
|
||||
this.clear();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The first object in the collision
|
||||
*/
|
||||
public a;
|
||||
|
||||
/**
|
||||
* The second object in the collision
|
||||
*/
|
||||
public b;
|
||||
|
||||
/**
|
||||
* The shortest colliding axis (unit-vector)
|
||||
*/
|
||||
public overlapN: Vec2;
|
||||
|
||||
/**
|
||||
* The overlap vector (i.e. overlapN.scale(overlap, overlap)).
|
||||
* If this vector is subtracted from the position of `a`, `a` and `b` will no longer be colliding.
|
||||
*/
|
||||
public overlapV: Vec2;
|
||||
|
||||
/**
|
||||
* Whether the first object is completely inside the second.
|
||||
*/
|
||||
public aInB: bool;
|
||||
|
||||
/**
|
||||
* Whether the second object is completely inside the first.
|
||||
*/
|
||||
public bInA: bool;
|
||||
|
||||
/**
|
||||
* Magnitude of the overlap on the shortest colliding axis
|
||||
*/
|
||||
public overlap: number;
|
||||
|
||||
/**
|
||||
* Set some values of the response back to their defaults. Call this between tests if
|
||||
* you are going to reuse a single Response object for multiple intersection tests (recommented)
|
||||
*
|
||||
* @return {Response} This for chaining
|
||||
*/
|
||||
public clear() {
|
||||
|
||||
this.aInB = true;
|
||||
this.bInA = true;
|
||||
this.overlap = Number.MAX_VALUE;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,13 @@
|
|||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../Signal.ts" />
|
||||
/// <reference path="../core/Signal.ts" />
|
||||
/// <reference path="../utils/PointUtils.ts" />
|
||||
/// <reference path="../math/Vec2Utils.ts" />
|
||||
/// <reference path="Pointer.ts" />
|
||||
/// <reference path="MSPointer.ts" />
|
||||
/// <reference path="Gestures.ts" />
|
||||
/// <reference path="../utils/PointUtils.ts" />
|
||||
/// <reference path="../math/Vec2Utils.ts" />
|
||||
/// <reference path="Mouse.ts" />
|
||||
/// <reference path="Keyboard.ts" />
|
||||
/// <reference path="Touch.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Input
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../gameobjects/IGameObject.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - LinkedList
|
||||
|
@ -21,9 +22,9 @@ module Phaser {
|
|||
}
|
||||
|
||||
/**
|
||||
* Stores a reference to an <code>Basic</code>.
|
||||
* Stores a reference to an <code>IGameObject</code>.
|
||||
*/
|
||||
public object: Basic;
|
||||
public object: IGameObject;
|
||||
|
||||
/**
|
||||
* Stores a reference to the next link in the list.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="LinkedList.ts" />
|
||||
/// <reference path="../gameobjects/IGameObject.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - QuadTree
|
||||
|
@ -32,42 +33,39 @@ module Phaser {
|
|||
//Copy the parent's children (if there are any)
|
||||
if (parent != null)
|
||||
{
|
||||
var iterator: LinkedList;
|
||||
var ot: LinkedList;
|
||||
|
||||
if (parent._headA.object != null)
|
||||
{
|
||||
iterator = parent._headA;
|
||||
this._iterator = parent._headA;
|
||||
|
||||
while (iterator != null)
|
||||
while (this._iterator != null)
|
||||
{
|
||||
if (this._tailA.object != null)
|
||||
{
|
||||
ot = this._tailA;
|
||||
this._ot = this._tailA;
|
||||
this._tailA = new LinkedList();
|
||||
ot.next = this._tailA;
|
||||
this._ot.next = this._tailA;
|
||||
}
|
||||
|
||||
this._tailA.object = iterator.object;
|
||||
iterator = iterator.next;
|
||||
this._tailA.object = this._iterator.object;
|
||||
this._iterator = this._iterator.next;
|
||||
}
|
||||
}
|
||||
|
||||
if (parent._headB.object != null)
|
||||
{
|
||||
iterator = parent._headB;
|
||||
this._iterator = parent._headB;
|
||||
|
||||
while (iterator != null)
|
||||
while (this._iterator != null)
|
||||
{
|
||||
if (this._tailB.object != null)
|
||||
{
|
||||
ot = this._tailB;
|
||||
this._ot = this._tailB;
|
||||
this._tailB = new LinkedList();
|
||||
ot.next = this._tailB;
|
||||
this._ot.next = this._tailB;
|
||||
}
|
||||
|
||||
this._tailB.object = iterator.object;
|
||||
iterator = iterator.next;
|
||||
this._tailB.object = this._iterator.object;
|
||||
this._iterator = this._iterator.next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,6 +92,16 @@ module Phaser {
|
|||
|
||||
}
|
||||
|
||||
// Reused temporary vars to help avoid gc spikes
|
||||
private _iterator: LinkedList;
|
||||
private _ot: LinkedList;
|
||||
private _i;
|
||||
private _basic;
|
||||
private _members;
|
||||
private _l: number;
|
||||
private _overlapProcessed: bool;
|
||||
private _checkObject;
|
||||
|
||||
/**
|
||||
* Flag for specifying that you want to add an object to the A list.
|
||||
*/
|
||||
|
@ -287,13 +295,13 @@ module Phaser {
|
|||
/**
|
||||
* Load objects and/or groups into the quad tree, and register notify and processing callbacks.
|
||||
*
|
||||
* @param {Basic} objectOrGroup1 Any object that is or extends GameObject or Group.
|
||||
* @param {Basic} objectOrGroup2 Any object that is or extends GameObject or Group. If null, the first parameter will be checked against itself.
|
||||
* @param {} objectOrGroup1 Any object that is or extends IGameObject or Group.
|
||||
* @param {} objectOrGroup2 Any object that is or extends IGameObject or Group. If null, the first parameter will be checked against itself.
|
||||
* @param {Function} notifyCallback A function with the form <code>myFunction(Object1:GameObject,Object2:GameObject)</code> that is called whenever two objects are found to overlap in world space, and either no processCallback is specified, or the processCallback returns true.
|
||||
* @param {Function} processCallback A function with the form <code>myFunction(Object1:GameObject,Object2:GameObject):bool</code> that is called whenever two objects are found to overlap in world space. The notifyCallback is only called if this function returns true. See GameObject.separate().
|
||||
* @param context The context in which the callbacks will be called
|
||||
*/
|
||||
public load(objectOrGroup1: Basic, objectOrGroup2: Basic = null, notifyCallback = null, processCallback = null, context = null) {
|
||||
public load(objectOrGroup1, objectOrGroup2 = null, notifyCallback = null, processCallback = null, context = null) {
|
||||
|
||||
this.add(objectOrGroup1, QuadTree.A_LIST);
|
||||
|
||||
|
@ -318,33 +326,32 @@ module Phaser {
|
|||
* This function will recursively add all group members, but
|
||||
* not the groups themselves.
|
||||
*
|
||||
* @param {Basic} objectOrGroup GameObjects are just added, Groups are recursed and their applicable members added accordingly.
|
||||
* @param {} objectOrGroup GameObjects are just added, Groups are recursed and their applicable members added accordingly.
|
||||
* @param {Number} list A <code>uint</code> flag indicating the list to which you want to add the objects. Options are <code>QuadTree.A_LIST</code> and <code>QuadTree.B_LIST</code>.
|
||||
*/
|
||||
public add(objectOrGroup: Basic, list: number) {
|
||||
public add(objectOrGroup, list: number) {
|
||||
|
||||
QuadTree._list = list;
|
||||
|
||||
if (objectOrGroup.isGroup == true)
|
||||
{
|
||||
var i: number = 0;
|
||||
var basic: Basic;
|
||||
var members = <Group> objectOrGroup['members'];
|
||||
var l: number = objectOrGroup['length'];
|
||||
this._i = 0;
|
||||
this._members = <Group> objectOrGroup['members'];
|
||||
this._l = objectOrGroup['length'];
|
||||
|
||||
while (i < l)
|
||||
while (this._i < this._l)
|
||||
{
|
||||
basic = members[i++];
|
||||
this._basic = this._members[this._i++];
|
||||
|
||||
if ((basic != null) && basic.exists)
|
||||
if (this._basic != null && this._basic.exists)
|
||||
{
|
||||
if (basic.isGroup)
|
||||
if (this._basic.type == Phaser.Types.GROUP)
|
||||
{
|
||||
this.add(basic, list);
|
||||
this.add(this._basic, list);
|
||||
}
|
||||
else
|
||||
{
|
||||
QuadTree._object = basic;
|
||||
QuadTree._object = this._basic;
|
||||
|
||||
if (QuadTree._object.exists && QuadTree._object.allowCollisions)
|
||||
{
|
||||
|
@ -477,15 +484,13 @@ module Phaser {
|
|||
*/
|
||||
private addToList() {
|
||||
|
||||
var ot: LinkedList;
|
||||
|
||||
if (QuadTree._list == QuadTree.A_LIST)
|
||||
{
|
||||
if (this._tailA.object != null)
|
||||
{
|
||||
ot = this._tailA;
|
||||
this._ot = this._tailA;
|
||||
this._tailA = new LinkedList();
|
||||
ot.next = this._tailA;
|
||||
this._ot.next = this._tailA;
|
||||
}
|
||||
|
||||
this._tailA.object = QuadTree._object;
|
||||
|
@ -494,9 +499,9 @@ module Phaser {
|
|||
{
|
||||
if (this._tailB.object != null)
|
||||
{
|
||||
ot = this._tailB;
|
||||
this._ot = this._tailB;
|
||||
this._tailB = new LinkedList();
|
||||
ot.next = this._tailB;
|
||||
this._ot.next = this._tailB;
|
||||
}
|
||||
|
||||
this._tailB.object = QuadTree._object;
|
||||
|
@ -537,16 +542,15 @@ module Phaser {
|
|||
*/
|
||||
public execute(): bool {
|
||||
|
||||
var overlapProcessed: bool = false;
|
||||
var iterator: LinkedList;
|
||||
this._overlapProcessed = false;
|
||||
|
||||
if (this._headA.object != null)
|
||||
{
|
||||
iterator = this._headA;
|
||||
this._iterator = this._headA;
|
||||
|
||||
while (iterator != null)
|
||||
while (this._iterator != null)
|
||||
{
|
||||
QuadTree._object = iterator.object;
|
||||
QuadTree._object = this._iterator.object;
|
||||
|
||||
if (QuadTree._useBothLists)
|
||||
{
|
||||
|
@ -554,15 +558,15 @@ module Phaser {
|
|||
}
|
||||
else
|
||||
{
|
||||
QuadTree._iterator = iterator.next;
|
||||
QuadTree._iterator = this._iterator.next;
|
||||
}
|
||||
|
||||
if (QuadTree._object.exists && (QuadTree._object.allowCollisions > 0) && (QuadTree._iterator != null) && (QuadTree._iterator.object != null) && QuadTree._iterator.object.exists && this.overlapNode())
|
||||
{
|
||||
overlapProcessed = true;
|
||||
this._overlapProcessed = true;
|
||||
}
|
||||
|
||||
iterator = iterator.next;
|
||||
this._iterator = this._iterator.next;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -570,25 +574,25 @@ module Phaser {
|
|||
//Advance through the tree by calling overlap on each child
|
||||
if ((this._northWestTree != null) && this._northWestTree.execute())
|
||||
{
|
||||
overlapProcessed = true;
|
||||
this._overlapProcessed = true;
|
||||
}
|
||||
|
||||
if ((this._northEastTree != null) && this._northEastTree.execute())
|
||||
{
|
||||
overlapProcessed = true;
|
||||
this._overlapProcessed = true;
|
||||
}
|
||||
|
||||
if ((this._southEastTree != null) && this._southEastTree.execute())
|
||||
{
|
||||
overlapProcessed = true;
|
||||
this._overlapProcessed = true;
|
||||
}
|
||||
|
||||
if ((this._southWestTree != null) && this._southWestTree.execute())
|
||||
{
|
||||
overlapProcessed = true;
|
||||
this._overlapProcessed = true;
|
||||
}
|
||||
|
||||
return overlapProcessed;
|
||||
return this._overlapProcessed;
|
||||
|
||||
}
|
||||
|
||||
|
@ -600,8 +604,7 @@ module Phaser {
|
|||
private overlapNode(): bool {
|
||||
|
||||
//Walk the list and check for overlaps
|
||||
var overlapProcessed: bool = false;
|
||||
var checkObject;
|
||||
this._overlapProcessed = false;
|
||||
|
||||
while (QuadTree._iterator != null)
|
||||
{
|
||||
|
@ -610,31 +613,31 @@ module Phaser {
|
|||
break;
|
||||
}
|
||||
|
||||
checkObject = QuadTree._iterator.object;
|
||||
this._checkObject = QuadTree._iterator.object;
|
||||
|
||||
if ((QuadTree._object === checkObject) || !checkObject.exists || (checkObject.allowCollisions <= 0))
|
||||
if ((QuadTree._object === this._checkObject) || !this._checkObject.exists || (this._checkObject.allowCollisions <= 0))
|
||||
{
|
||||
QuadTree._iterator = QuadTree._iterator.next;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (QuadTree._object.collisionMask.checkHullIntersection(checkObject.collisionMask))
|
||||
if (QuadTree._object.collisionMask.checkHullIntersection(this._checkObject.collisionMask))
|
||||
{
|
||||
//Execute callback functions if they exist
|
||||
if ((QuadTree._processingCallback == null) || QuadTree._processingCallback(QuadTree._object, checkObject))
|
||||
if ((QuadTree._processingCallback == null) || QuadTree._processingCallback(QuadTree._object, this._checkObject))
|
||||
{
|
||||
overlapProcessed = true;
|
||||
this._overlapProcessed = true;
|
||||
}
|
||||
|
||||
if (overlapProcessed && (QuadTree._notifyCallback != null))
|
||||
if (this._overlapProcessed && (QuadTree._notifyCallback != null))
|
||||
{
|
||||
if (QuadTree._callbackContext !== null)
|
||||
{
|
||||
QuadTree._notifyCallback.call(QuadTree._callbackContext, QuadTree._object, checkObject);
|
||||
QuadTree._notifyCallback.call(QuadTree._callbackContext, QuadTree._object, this._checkObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
QuadTree._notifyCallback(QuadTree._object, checkObject);
|
||||
QuadTree._notifyCallback(QuadTree._object, this._checkObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -643,7 +646,7 @@ module Phaser {
|
|||
|
||||
}
|
||||
|
||||
return overlapProcessed;
|
||||
return this._overlapProcessed;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/**
|
||||
* Phaser
|
||||
*
|
||||
* v1.0.0 - June XX 2013
|
||||
*
|
||||
* A small and feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi.
|
||||
*
|
||||
* Richard Davey (@photonstorm)
|
||||
*
|
||||
* Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel, from both which Phaser
|
||||
* and my love of game development took a lot of inspiration.
|
||||
*
|
||||
* "If you want your children to be intelligent, read them fairy tales."
|
||||
* "If you want them to be more intelligent, read them more fairy tales."
|
||||
* -- Albert Einstein
|
||||
*/
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
Phaser.VERSION = 'Phaser version 1.0.0';
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../RenderManager.ts" />
|
||||
/// <reference path="../gameobjects/Sprite.ts" />
|
||||
/// <reference path="../cameras/Camera.ts" />
|
||||
/// <reference path="IRenderer.ts" />
|
||||
|
@ -8,16 +7,14 @@ module Phaser {
|
|||
|
||||
export class CanvasRenderer implements Phaser.IRenderer {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
constructor(game: Phaser.Game) {
|
||||
this._game = game;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The essential reference to the main game object
|
||||
*/
|
||||
private _game: Game;
|
||||
private _game: Phaser.Game;
|
||||
|
||||
// local rendering related temp vars to help avoid gc spikes with var creation
|
||||
private _sx: number = 0;
|
||||
|
@ -28,6 +25,8 @@ module Phaser {
|
|||
private _dy: number = 0;
|
||||
private _dw: number = 0;
|
||||
private _dh: number = 0;
|
||||
private _fx: number = 1;
|
||||
private _fy: number = 1;
|
||||
|
||||
private _cameraList;
|
||||
private _camera: Camera;
|
||||
|
@ -73,15 +72,29 @@ module Phaser {
|
|||
sprite.texture.context.globalAlpha = sprite.texture.alpha;
|
||||
}
|
||||
|
||||
this._fx = sprite.scale.x;
|
||||
this._fy = sprite.scale.y;
|
||||
this._sx = 0;
|
||||
this._sy = 0;
|
||||
this._sw = sprite.frameBounds.width;
|
||||
this._sh = sprite.frameBounds.height;
|
||||
|
||||
//if (sprite.texture.flippedX)
|
||||
//{
|
||||
// this._fx = -1;
|
||||
//}
|
||||
|
||||
//if (sprite.texture.flippedY)
|
||||
//{
|
||||
// this._fy = -1;
|
||||
//}
|
||||
|
||||
this._dx = (camera.scaledX * sprite.scrollFactor.x) + sprite.frameBounds.x - (camera.worldView.x * sprite.scrollFactor.x);
|
||||
this._dy = (camera.scaledY * sprite.scrollFactor.y) + sprite.frameBounds.y - (camera.worldView.y * sprite.scrollFactor.y);
|
||||
this._dw = sprite.frameBounds.width * sprite.scale.x;
|
||||
this._dh = sprite.frameBounds.height * sprite.scale.y;
|
||||
//this._dw = sprite.frameBounds.width * sprite.scale.x;
|
||||
//this._dh = sprite.frameBounds.height * sprite.scale.y;
|
||||
this._dw = sprite.frameBounds.width;
|
||||
this._dh = sprite.frameBounds.height;
|
||||
|
||||
/*
|
||||
if (this._dynamicTexture == false && this.animations.currentFrame !== null)
|
||||
|
@ -104,11 +117,35 @@ module Phaser {
|
|||
//this._dy -= (camera.worldView.y * this.scrollFactor.y);
|
||||
}
|
||||
|
||||
// Apply origin / alignment
|
||||
if (sprite.origin.x != 0 || sprite.origin.y != 0)
|
||||
{
|
||||
//this._dx += (sprite.origin.x * sprite.scale.x);
|
||||
//this._dy += (sprite.origin.y * sprite.scale.y);
|
||||
}
|
||||
|
||||
// Rotation and Flipped
|
||||
if (sprite.position.rotation !== 0 || sprite.position.rotationOffset !== 0 || sprite.texture.flippedX || sprite.texture.flippedY)
|
||||
if (sprite.scale.x != 1 || sprite.scale.y != 1 || sprite.position.rotation != 0 || sprite.position.rotationOffset != 0 || sprite.texture.flippedX || sprite.texture.flippedY)
|
||||
//if (sprite.position.rotation != 0 || sprite.position.rotationOffset != 0 || sprite.texture.flippedX || sprite.texture.flippedY)
|
||||
{
|
||||
sprite.texture.context.save();
|
||||
sprite.texture.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
|
||||
if (sprite.texture.flippedX)
|
||||
{
|
||||
this._dx += this._dw * sprite.scale.x;
|
||||
}
|
||||
|
||||
if (sprite.texture.flippedY)
|
||||
{
|
||||
this._dy += this._dh * sprite.scale.y;
|
||||
}
|
||||
|
||||
sprite.texture.context.translate(this._dx, this._dy);
|
||||
|
||||
//sprite.texture.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
//sprite.texture.context.translate(this._dx + (sprite.origin.x * sprite.scale.x), this._dy + (sprite.origin.y * sprite.scale.y));
|
||||
//sprite.texture.context.translate(this._dx + sprite.origin.x, this._dy + sprite.origin.y);
|
||||
//sprite.texture.context.translate(this._dx + sprite.origin.x - (this._dw / 2), this._dy + sprite.origin.y - (this._dh / 2));
|
||||
|
||||
if (sprite.texture.renderRotation == true && (sprite.position.rotation !== 0 || sprite.position.rotationOffset !== 0))
|
||||
{
|
||||
|
@ -116,15 +153,42 @@ module Phaser {
|
|||
sprite.texture.context.rotate((sprite.position.rotationOffset + sprite.position.rotation) * (Math.PI / 180));
|
||||
}
|
||||
|
||||
this._dx = -(this._dw / 2);
|
||||
this._dy = -(this._dh / 2);
|
||||
|
||||
if (sprite.texture.flippedX || sprite.texture.flippedY)
|
||||
if (sprite.scale.x != 1 || sprite.scale.y != 1 || sprite.texture.flippedX || sprite.texture.flippedY)
|
||||
{
|
||||
if (sprite.texture.flippedX)
|
||||
{
|
||||
sprite.texture.context.scale(-1, 1);
|
||||
this._fx = -sprite.scale.x;
|
||||
}
|
||||
|
||||
if (sprite.texture.flippedY)
|
||||
{
|
||||
this._fy = -sprite.scale.y;
|
||||
}
|
||||
|
||||
sprite.texture.context.scale(this._fx, this._fy);
|
||||
|
||||
}
|
||||
|
||||
//if (sprite.texture.flippedX || sprite.texture.flippedY)
|
||||
//{
|
||||
// sprite.texture.context.scale(this._fx, this._fy);
|
||||
//}
|
||||
|
||||
this._dx = -(sprite.origin.x * sprite.scale.x);
|
||||
this._dy = -(sprite.origin.y * sprite.scale.y);
|
||||
//this._dx = -(sprite.origin.x * sprite.scale.x);
|
||||
//this._dy = -(sprite.origin.y * sprite.scale.y);
|
||||
//this._dx = -(this._dw / 2) * sprite.scale.x;
|
||||
//this._dy = -(this._dh / 2) * sprite.scale.y;
|
||||
//this._dx = 0;
|
||||
//this._dy = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sprite.origin.x != 0 || sprite.origin.y != 0)
|
||||
{
|
||||
//this._dx -= (sprite.origin.x * sprite.scale.x);
|
||||
//this._dy -= (sprite.origin.y * sprite.scale.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +221,8 @@ module Phaser {
|
|||
// this.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
//}
|
||||
|
||||
if (sprite.position.rotation !== 0 || sprite.position.rotationOffset !== 0 || sprite.texture.flippedX || sprite.texture.flippedY)
|
||||
if (sprite.scale.x != 1 || sprite.scale.y != 1 || sprite.position.rotation != 0 || sprite.position.rotationOffset != 0 || sprite.texture.flippedX || sprite.texture.flippedY)
|
||||
//if (sprite.position.rotation != 0 || sprite.position.rotationOffset != 0 || sprite.texture.flippedX || sprite.texture.flippedY)
|
||||
{
|
||||
//this.context.translate(0, 0);
|
||||
sprite.texture.context.restore();
|
||||
|
|
|
@ -6,14 +6,14 @@ module Phaser {
|
|||
|
||||
export class HeadlessRenderer implements Phaser.IRenderer {
|
||||
|
||||
constructor(game: Game) {
|
||||
constructor(game: Phaser.Game) {
|
||||
this._game = game;
|
||||
}
|
||||
|
||||
/**
|
||||
* The essential reference to the main game object
|
||||
*/
|
||||
private _game: Game;
|
||||
private _game: Phaser.Game;
|
||||
|
||||
public render() {}
|
||||
|
||||
|
|
|
@ -4,10 +4,6 @@ module Phaser {
|
|||
|
||||
export interface IRenderer {
|
||||
|
||||
// properties
|
||||
_game: Game;
|
||||
|
||||
// methods
|
||||
render();
|
||||
renderSprite(camera: Camera, sprite: Sprite): bool;
|
||||
|
||||
|
|
|
@ -195,6 +195,18 @@ module Phaser {
|
|||
|
||||
}
|
||||
|
||||
public clear() {
|
||||
|
||||
this._chainedTweens = [];
|
||||
|
||||
this.onStart.removeAll();
|
||||
this.onUpdate.removeAll();
|
||||
this.onComplete.removeAll();
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop tweening.
|
||||
*/
|
||||
|
|
|
@ -36,7 +36,8 @@ module Phaser {
|
|||
* @return {Boolean} True if the coordinates are within this circle, otherwise false.
|
||||
**/
|
||||
static contains(a: Circle, x: number, y: number): bool {
|
||||
return (a.radius * a.radius >= Collision.distanceSquared(a.x, a.y, x, y));
|
||||
//return (a.radius * a.radius >= Collision.distanceSquared(a.x, a.y, x, y));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,7 +60,8 @@ module Phaser {
|
|||
* @return {Boolean} True if the coordinates are within this circle, otherwise false.
|
||||
**/
|
||||
static containsCircle(a:Circle, b:Circle): bool {
|
||||
return ((a.radius + b.radius) * (a.radius + b.radius)) >= Collision.distanceSquared(a.x, a.y, b.x, b.y);
|
||||
//return ((a.radius + b.radius) * (a.radius + b.radius)) >= Collision.distanceSquared(a.x, a.y, b.x, b.y);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -341,65 +341,6 @@ module Phaser {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load graphic for this sprite. (graphic can be SpriteSheet or Texture)
|
||||
* @param key {string} Key of the graphic you want to load for this sprite.
|
||||
* @param clearAnimations {boolean} If this Sprite has a set of animation data already loaded you can choose to keep or clear it with this boolean
|
||||
* @return {Sprite} Sprite instance itself.
|
||||
*/
|
||||
static loadTexture(sprite: Phaser.Sprite, key: string, clearAnimations: bool = true): Sprite {
|
||||
|
||||
//if (clearAnimations && sprite.animations.frameData !== null)
|
||||
//{
|
||||
// sprite.animations.destroy();
|
||||
//}
|
||||
|
||||
if (sprite.game.cache.getImage(key) !== null)
|
||||
{
|
||||
if (sprite.game.cache.isSpriteSheet(key))
|
||||
{
|
||||
sprite.texture.setTo(null, sprite.game.cache.getImage(key));
|
||||
//sprite.animations.loadFrameData(sprite._game.cache.getFrameData(key));
|
||||
//sprite.collisionMask.width = sprite.animations.currentFrame.width;
|
||||
//sprite.collisionMask.height = sprite.animations.currentFrame.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite.texture.setTo(sprite.game.cache.getImage(key), null);
|
||||
sprite.frameBounds.width = sprite.texture.width;
|
||||
sprite.frameBounds.height = sprite.texture.height;
|
||||
//sprite.collisionMask.width = sprite._texture.width;
|
||||
//sprite.collisionMask.height = sprite._texture.height;
|
||||
}
|
||||
}
|
||||
|
||||
return sprite;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a DynamicTexture as its texture.
|
||||
* @param texture {DynamicTexture} The texture object to be used by this sprite.
|
||||
* @return {Sprite} Sprite instance itself.
|
||||
*/
|
||||
static loadDynamicTexture(sprite: Phaser.Sprite, texture: DynamicTexture): Sprite {
|
||||
|
||||
//if (sprite.animations.frameData !== null)
|
||||
//{
|
||||
// sprite.animations.destroy();
|
||||
//}
|
||||
|
||||
//sprite._texture = texture;
|
||||
|
||||
//sprite.frameBounds.width = sprite._texture.width;
|
||||
//sprite.frameBounds.height = sprite._texture.height;
|
||||
|
||||
//sprite._dynamicTexture = true;
|
||||
|
||||
return sprite;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This function creates a flat colored square image dynamically.
|
||||
* @param width {number} The width of the sprite you want to generate.
|
||||
|
|
|
@ -38,7 +38,7 @@ V1.0.0
|
|||
* Heavily optimised Group so it no longer creates any temporary variables in any methods.
|
||||
* Added Game.renderer which can be HEADLESS, CANVAS or WEBGL (coming soon)
|
||||
* Added Sprite.render which is a reference to IRenderer.renderSprite, but can be overridden for custom handling.
|
||||
|
||||
* Refactored QuadTree so it no longer creates any temporary variables in any methods.
|
||||
|
||||
|
||||
V0.9.6
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
/// <reference path="../../Phaser/Game.d.ts" />
|
||||
/// <reference path="../../Phaser/system/Camera.d.ts" />
|
||||
/// <reference path="../../Phaser/FXManager.d.ts" />
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Border
|
||||
|
@ -44,13 +42,13 @@ module Phaser.FX.Camera {
|
|||
* Post-render is called during the objects render cycle, after the children/image data has been rendered.
|
||||
* It happens directly BEFORE a canvas context.restore has happened if added to a Camera.
|
||||
*/
|
||||
public postRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
|
||||
public postRender(camera: Phaser.Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
|
||||
|
||||
if (this.showBorder == true)
|
||||
{
|
||||
this._game.stage.context.strokeStyle = this.borderColor;
|
||||
this._game.stage.context.lineWidth = 1;
|
||||
this._game.stage.context.rect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
this._game.stage.context.rect(camera.scaledX, camera.scaledY, camera.worldView.width, camera.worldView.height);
|
||||
this._game.stage.context.stroke();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/// <reference path="../../Phaser/Game.d.ts" />
|
||||
/// <reference path="../../Phaser/FXManager.d.ts" />
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Fade
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/// <reference path="../../Phaser/Game.d.ts" />
|
||||
/// <reference path="../../Phaser/FXManager.d.ts" />
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Flash
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
/// <reference path="../../Phaser/Game.d.ts" />
|
||||
/// <reference path="../../Phaser/system/Camera.d.ts" />
|
||||
/// <reference path="../../Phaser/FXManager.d.ts" />
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Mirror
|
||||
|
@ -49,7 +47,7 @@ module Phaser.FX.Camera {
|
|||
* This is the rectangular region to grab from the Camera used in the Mirror effect
|
||||
* It is rendered to the Stage at Mirror.x/y (note the use of Stage coordinates, not World coordinates)
|
||||
*/
|
||||
public start(x: number, y: number, region: Phaser.Quad, fillColor?: string = 'rgba(0, 0, 100, 0.5)') {
|
||||
public start(x: number, y: number, region: Phaser.Rectangle, fillColor?: string = 'rgba(0, 0, 100, 0.5)') {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
@ -73,10 +71,10 @@ module Phaser.FX.Camera {
|
|||
*/
|
||||
public postRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
|
||||
|
||||
if (this.cls)
|
||||
{
|
||||
this._context.clearRect(0, 0, this._mirrorWidth, this._mirrorHeight);
|
||||
}
|
||||
//if (this.cls)
|
||||
//{
|
||||
// this._context.clearRect(0, 0, this._mirrorWidth, this._mirrorHeight);
|
||||
//}
|
||||
|
||||
this._sx = cameraX + this._mirrorX;
|
||||
this._sy = cameraY + this._mirrorY;
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
/// <reference path="../../Phaser/Game.d.ts" />
|
||||
/// <reference path="../../Phaser/system/Camera.d.ts" />
|
||||
/// <reference path="../../Phaser/FXManager.d.ts" />
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Scanlines
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
/// <reference path="../../Phaser/Game.d.ts" />
|
||||
/// <reference path="../../Phaser/system/Camera.d.ts" />
|
||||
/// <reference path="../../Phaser/FXManager.d.ts" />
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Shadow
|
||||
|
@ -42,9 +40,9 @@ module Phaser.FX.Camera {
|
|||
|
||||
/**
|
||||
* Offset of the shadow from camera's position.
|
||||
* @type {MicroPoint}
|
||||
* @type {Point}
|
||||
*/
|
||||
public shadowOffset: MicroPoint = new MicroPoint(4, 4);
|
||||
public shadowOffset: Point = new Point(4, 4);
|
||||
|
||||
/**
|
||||
* You can name the function that starts the effect whatever you like, but we used 'start' in our effects.
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/// <reference path="../../Phaser/Game.d.ts" />
|
||||
/// <reference path="../../Phaser/FXManager.d.ts" />
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Shake
|
||||
|
@ -24,7 +23,7 @@ module Phaser.FX.Camera {
|
|||
private _fxShakeIntensity: number = 0;
|
||||
private _fxShakeDuration: number = 0;
|
||||
private _fxShakeComplete = null;
|
||||
private _fxShakeOffset: MicroPoint = new MicroPoint(0, 0);
|
||||
private _fxShakeOffset: Point = new Point(0, 0);
|
||||
private _fxShakeDirection: number = 0;
|
||||
private _fxShakePrevX: number = 0;
|
||||
private _fxShakePrevY: number = 0;
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
/// <reference path="../../Phaser/Game.d.ts" />
|
||||
/// <reference path="../../Phaser/system/Camera.d.ts" />
|
||||
/// <reference path="../../Phaser/FXManager.d.ts" />
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Template
|
||||
|
|
|
@ -53,279 +53,38 @@
|
|||
<TypeScriptSourceMap>false</TypeScriptSourceMap>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<TypeScriptCompile Include="camera fx\flash.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera alpha.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera bounds.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera position.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera rotation.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera scale.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera shadow.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera texture.ts" />
|
||||
<TypeScriptCompile Include="cameras\focus on.ts" />
|
||||
<TypeScriptCompile Include="cameras\follow deadzone.ts" />
|
||||
<TypeScriptCompile Include="cameras\follow sprite.ts" />
|
||||
<TypeScriptCompile Include="cameras\follow topdown.ts" />
|
||||
<TypeScriptCompile Include="cameras\multicam1.ts" />
|
||||
<TypeScriptCompile Include="cameras\scroll factor.ts" />
|
||||
<TypeScriptCompile Include="collision\collide sprites.ts" />
|
||||
<TypeScriptCompile Include="collision\falling balls.ts" />
|
||||
<TypeScriptCompile Include="groups\basic group.ts" />
|
||||
<TypeScriptCompile Include="input\mouse scale.ts" />
|
||||
<TypeScriptCompile Include="mini games\formula 1.ts" />
|
||||
<TypeScriptCompile Include="misc\multi game.ts" />
|
||||
<TypeScriptCompile Include="particles\basic emitter.ts" />
|
||||
<TypeScriptCompile Include="particles\graphic emitter.ts" />
|
||||
<TypeScriptCompile Include="particles\multiple streams.ts" />
|
||||
<TypeScriptCompile Include="particles\sprite emitter.ts" />
|
||||
<TypeScriptCompile Include="particles\when particles collide.ts" />
|
||||
<TypeScriptCompile Include="sprites\animation 1.ts" />
|
||||
<TypeScriptCompile Include="sprites\mark of the bunny.ts" />
|
||||
<TypeScriptCompile Include="sprites\texture atlas 2.ts" />
|
||||
<TypeScriptCompile Include="sprites\texture atlas 3.ts" />
|
||||
<TypeScriptCompile Include="sprites\texture atlas 4.ts" />
|
||||
<TypeScriptCompile Include="sprites\texture atlas.ts" />
|
||||
<TypeScriptCompile Include="sprites\velocity.ts" />
|
||||
<TypeScriptCompile Include="tilemap\basic tilemap.ts" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<TypeScriptCompile Include="sprites\dynamic texture 1.ts" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<TypeScriptCompile Include="sprites\align.ts" />
|
||||
<TypeScriptCompile Include="scrollzones\simple scrollzone.ts" />
|
||||
<TypeScriptCompile Include="scrollzones\ballscroller.ts" />
|
||||
<TypeScriptCompile Include="misc\bootscreen.ts" />
|
||||
<TypeScriptCompile Include="camera fx\fade.ts" />
|
||||
<Content Include="camera fx\fade.js">
|
||||
<DependentUpon>fade.ts</DependentUpon>
|
||||
<Content Include="sprites\create sprite 1.js">
|
||||
<DependentUpon>create sprite 1.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="camera fx\flash.js">
|
||||
<DependentUpon>flash.ts</DependentUpon>
|
||||
<TypeScriptCompile Include="sprites\scale origin 1.ts" />
|
||||
<Content Include="sprites\scale origin 1.js">
|
||||
<DependentUpon>scale origin 1.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="camera fx\shake.ts" />
|
||||
<TypeScriptCompile Include="camera fx\scanlines.ts" />
|
||||
<TypeScriptCompile Include="camera fx\mirror.ts" />
|
||||
<Content Include="camera fx\mirror.js">
|
||||
<DependentUpon>mirror.ts</DependentUpon>
|
||||
<Content Include="sprites\scale sprite 1.js">
|
||||
<DependentUpon>scale sprite 1.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="camera fx\scanlines.js">
|
||||
<DependentUpon>scanlines.ts</DependentUpon>
|
||||
<Content Include="sprites\scale sprite 2.js">
|
||||
<DependentUpon>scale sprite 2.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="camera fx\shake.js">
|
||||
<DependentUpon>shake.ts</DependentUpon>
|
||||
<Content Include="sprites\scale sprite 3.js">
|
||||
<DependentUpon>scale sprite 3.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="input\multitouch.ts" />
|
||||
<TypeScriptCompile Include="groups\display order.ts" />
|
||||
<TypeScriptCompile Include="collision\mask test 1.ts" />
|
||||
<TypeScriptCompile Include="collision\mask animation 1.ts" />
|
||||
<Content Include="collision\mask animation 1.js">
|
||||
<DependentUpon>mask animation 1.ts</DependentUpon>
|
||||
<Content Include="sprites\scale sprite 4.js">
|
||||
<DependentUpon>scale sprite 4.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="collision\mask test 1.js">
|
||||
<DependentUpon>mask test 1.ts</DependentUpon>
|
||||
<Content Include="sprites\scale sprite 5.js">
|
||||
<DependentUpon>scale sprite 5.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="collision\mask test 2.ts" />
|
||||
<Content Include="collision\mask test 2.js">
|
||||
<DependentUpon>mask test 2.ts</DependentUpon>
|
||||
<TypeScriptCompile Include="sprites\scale sprite 5.ts" />
|
||||
<TypeScriptCompile Include="sprites\scale sprite 4.ts" />
|
||||
<TypeScriptCompile Include="sprites\scale sprite 3.ts" />
|
||||
<TypeScriptCompile Include="sprites\scale sprite 2.ts" />
|
||||
<TypeScriptCompile Include="sprites\scale sprite 1.ts" />
|
||||
<TypeScriptCompile Include="sprites\create sprite 1.ts" />
|
||||
<TypeScriptCompile Include="misc\boot screen.ts" />
|
||||
<Content Include="misc\boot screen.js">
|
||||
<DependentUpon>boot screen.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geometry\multi rotate.ts" />
|
||||
<Content Include="geometry\multi rotate.js">
|
||||
<DependentUpon>multi rotate.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geometry\rotate point 2.ts" />
|
||||
<TypeScriptCompile Include="geometry\rotate point 1.ts" />
|
||||
<TypeScriptCompile Include="geometry\rope bridge.ts" />
|
||||
<Content Include="geometry\rope bridge.js">
|
||||
<DependentUpon>rope bridge.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geometry\rotate point 1.js">
|
||||
<DependentUpon>rotate point 1.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geometry\rotate point 2.js">
|
||||
<DependentUpon>rotate point 2.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geometry\rotate point 3.ts" />
|
||||
<Content Include="geometry\rotate point 3.js">
|
||||
<DependentUpon>rotate point 3.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geometry\verlet 1.ts" />
|
||||
<TypeScriptCompile Include="geometry\rotate point 4.ts" />
|
||||
<Content Include="geometry\rotate point 4.js">
|
||||
<DependentUpon>rotate point 4.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geometry\verlet 1.js">
|
||||
<DependentUpon>verlet 1.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geometry\verlet sprites.ts" />
|
||||
<Content Include="geometry\verlet sprites.js">
|
||||
<DependentUpon>verlet sprites.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="groups\display order.js">
|
||||
<DependentUpon>display order.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="input\multitouch.js">
|
||||
<DependentUpon>multitouch.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="input\single touch.ts" />
|
||||
<TypeScriptCompile Include="input\single tap.ts" />
|
||||
<Content Include="input\single tap.js">
|
||||
<DependentUpon>single tap.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="input\single touch.js">
|
||||
<DependentUpon>single touch.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="misc\bootscreen.js">
|
||||
<DependentUpon>bootscreen.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="mobile\sprite test 1.ts" />
|
||||
<TypeScriptCompile Include="mobile\bunny mobile.ts" />
|
||||
<TypeScriptCompile Include="misc\time.ts" />
|
||||
<TypeScriptCompile Include="misc\starfield.ts" />
|
||||
<Content Include="misc\starfield.js">
|
||||
<DependentUpon>starfield.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="misc\time.js">
|
||||
<DependentUpon>time.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="mobile\bunny mobile.js">
|
||||
<DependentUpon>bunny mobile.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="mobile\sprite test 1.js">
|
||||
<DependentUpon>sprite test 1.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="particles\mousetrail.ts" />
|
||||
<Content Include="particles\mousetrail.js">
|
||||
<DependentUpon>mousetrail.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="physics\temp1.ts" />
|
||||
<Content Include="physics\temp1.js">
|
||||
<DependentUpon>temp1.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="physics\temp2.ts" />
|
||||
<Content Include="physics\temp2.js">
|
||||
<DependentUpon>temp2.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="scrollzones\ballscroller.js">
|
||||
<DependentUpon>ballscroller.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="scrollzones\parallax.ts" />
|
||||
<TypeScriptCompile Include="scrollzones\blasteroids.ts" />
|
||||
<Content Include="scrollzones\blasteroids.js">
|
||||
<DependentUpon>blasteroids.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="scrollzones\parallax.js">
|
||||
<DependentUpon>parallax.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="scrollzones\scroll window.ts" />
|
||||
<TypeScriptCompile Include="scrollzones\region demo.ts" />
|
||||
<Content Include="scrollzones\region demo.js">
|
||||
<DependentUpon>region demo.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="scrollzones\scroll window.js">
|
||||
<DependentUpon>scroll window.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="scrollzones\simple scrollzone.js">
|
||||
<DependentUpon>simple scrollzone.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="sprites\align.js">
|
||||
<DependentUpon>align.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="sprites\flipped.ts" />
|
||||
<Content Include="sprites\flipped.js">
|
||||
<DependentUpon>flipped.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="tilemap\small map.ts" />
|
||||
<TypeScriptCompile Include="tilemap\get tile.ts" />
|
||||
<TypeScriptCompile Include="tilemap\collision.ts" />
|
||||
<TypeScriptCompile Include="tilemap\collide with tile.ts" />
|
||||
<TypeScriptCompile Include="sprites\starling texture atlas 1.ts" />
|
||||
<Content Include="sprites\starling texture atlas 1.js">
|
||||
<DependentUpon>starling texture atlas 1.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="tilemap\collide with tile.js">
|
||||
<DependentUpon>collide with tile.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="tilemap\collision.js">
|
||||
<DependentUpon>collision.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="tilemap\fill tiles.ts" />
|
||||
<Content Include="tilemap\fill tiles.js">
|
||||
<DependentUpon>fill tiles.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="tilemap\get tile.js">
|
||||
<DependentUpon>get tile.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="tilemap\put tile.ts" />
|
||||
<TypeScriptCompile Include="tilemap\map draw.ts" />
|
||||
<Content Include="tilemap\map draw.js">
|
||||
<DependentUpon>map draw.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="tilemap\put tile.js">
|
||||
<DependentUpon>put tile.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="tilemap\replace tiles.ts" />
|
||||
<TypeScriptCompile Include="tilemap\random tiles.ts" />
|
||||
<Content Include="tilemap\random tiles.js">
|
||||
<DependentUpon>random tiles.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="tilemap\replace tiles.js">
|
||||
<DependentUpon>replace tiles.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="tilemap\small map.js">
|
||||
<DependentUpon>small map.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="tilemap\swap tiles.ts" />
|
||||
<TypeScriptCompile Include="tilemap\sprite draw tiles.ts" />
|
||||
<Content Include="tilemap\sprite draw tiles.js">
|
||||
<DependentUpon>sprite draw tiles.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="tilemap\swap tiles.js">
|
||||
<DependentUpon>swap tiles.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="tweens\bounce.js">
|
||||
<DependentUpon>bounce.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="tweens\elastic.js">
|
||||
<DependentUpon>elastic.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="tweens\elastic.ts" />
|
||||
<TypeScriptCompile Include="tweens\bounce.ts" />
|
||||
<TypeScriptCompile Include="sprites\animate by framename.ts" />
|
||||
<TypeScriptCompile Include="geometry\rectangle.ts" />
|
||||
<TypeScriptCompile Include="geometry\rect vs rect.ts" />
|
||||
<TypeScriptCompile Include="geometry\circle.ts" />
|
||||
<Content Include="geometry\circle.js">
|
||||
<DependentUpon>circle.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geometry\point.ts" />
|
||||
<TypeScriptCompile Include="geometry\line.ts" />
|
||||
<Content Include="geometry\line.js">
|
||||
<DependentUpon>line.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geometry\point.js">
|
||||
<DependentUpon>point.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geometry\rect vs rect.js">
|
||||
<DependentUpon>rect vs rect.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geometry\rectangle.js">
|
||||
<DependentUpon>rectangle.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="sprites\animate by framename.js">
|
||||
<DependentUpon>animate by framename.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="sprites\dynamic texture 1.js">
|
||||
<DependentUpon>dynamic texture 1.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="sprites\dynamic texture 2.js">
|
||||
<DependentUpon>dynamic texture 2.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="sprites\rotation.js">
|
||||
<DependentUpon>rotation.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="sprites\rotation.ts" />
|
||||
<TypeScriptCompile Include="sprites\dynamic texture 2.ts" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
|
||||
</Project>
|
|
@ -1,46 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../build/phaser-fx.d.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('background', 'assets/pics/large-color-wheel.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var car;
|
||||
var fade;
|
||||
function create() {
|
||||
myGame.add.sprite(0, 0, 'background');
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
// Add our effect to the camera
|
||||
fade = myGame.camera.fx.add(Phaser.FX.Camera.Fade);
|
||||
}
|
||||
function update() {
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 300));
|
||||
}
|
||||
// Fade when the car hits the edges, a different colour per edge
|
||||
if(car.x < 0) {
|
||||
fade.start(0x330066, 3);
|
||||
car.x = 0;
|
||||
} else if(car.x > myGame.world.width) {
|
||||
fade.start(0x000066, 3);
|
||||
car.x = myGame.world.width - car.width;
|
||||
}
|
||||
if(car.y < 0) {
|
||||
fade.start(0xffffff, 4);
|
||||
car.y = 0;
|
||||
} else if(car.y > myGame.world.height) {
|
||||
fade.start(0x000000, 3);
|
||||
car.y = myGame.world.height - car.height;
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,77 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../build/phaser-fx.d.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.loader.addImageFile('background', 'assets/pics/large-color-wheel.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var car: Phaser.Sprite;
|
||||
var fade: Phaser.FX.Camera.Fade;
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.add.sprite(0, 0, 'background');
|
||||
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
|
||||
// Add our effect to the camera
|
||||
fade = <Phaser.FX.Camera.Fade> myGame.camera.fx.add(Phaser.FX.Camera.Fade);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 300));
|
||||
}
|
||||
|
||||
// Fade when the car hits the edges, a different colour per edge
|
||||
|
||||
if (car.x < 0)
|
||||
{
|
||||
fade.start(0x330066, 3);
|
||||
car.x = 0;
|
||||
}
|
||||
else if (car.x > myGame.world.width)
|
||||
{
|
||||
fade.start(0x000066, 3);
|
||||
car.x = myGame.world.width - car.width;
|
||||
}
|
||||
|
||||
if (car.y < 0)
|
||||
{
|
||||
fade.start(0xffffff, 4);
|
||||
car.y = 0;
|
||||
}
|
||||
else if (car.y > myGame.world.height)
|
||||
{
|
||||
fade.start(0x000000, 3);
|
||||
car.y = myGame.world.height - car.height;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,46 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../build/phaser-fx.d.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('background', 'assets/pics/large-color-wheel.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var car;
|
||||
var flash;
|
||||
function create() {
|
||||
myGame.add.sprite(0, 0, 'background');
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
// Add our effect to the camera
|
||||
flash = myGame.camera.fx.add(Phaser.FX.Camera.Flash);
|
||||
}
|
||||
function update() {
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 300));
|
||||
}
|
||||
// Flash when the car hits the edges, a different colour per edge
|
||||
if(car.x < 0) {
|
||||
flash.start(0xffffff, 1);
|
||||
car.x = 0;
|
||||
} else if(car.x > myGame.world.width) {
|
||||
flash.start(0xff0000, 2);
|
||||
car.x = myGame.world.width - car.width;
|
||||
}
|
||||
if(car.y < 0) {
|
||||
flash.start(0xffff00, 2);
|
||||
car.y = 0;
|
||||
} else if(car.y > myGame.world.height) {
|
||||
flash.start(0xff00ff, 3);
|
||||
car.y = myGame.world.height - car.height;
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,77 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../build/phaser-fx.d.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.loader.addImageFile('background', 'assets/pics/large-color-wheel.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var car: Phaser.Sprite;
|
||||
var flash: Phaser.FX.Camera.Flash;
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.add.sprite(0, 0, 'background');
|
||||
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
|
||||
// Add our effect to the camera
|
||||
flash = <Phaser.FX.Camera.Flash> myGame.camera.fx.add(Phaser.FX.Camera.Flash);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 300));
|
||||
}
|
||||
|
||||
// Flash when the car hits the edges, a different colour per edge
|
||||
|
||||
if (car.x < 0)
|
||||
{
|
||||
flash.start(0xffffff, 1);
|
||||
car.x = 0;
|
||||
}
|
||||
else if (car.x > myGame.world.width)
|
||||
{
|
||||
flash.start(0xff0000, 2);
|
||||
car.x = myGame.world.width - car.width;
|
||||
}
|
||||
|
||||
if (car.y < 0)
|
||||
{
|
||||
flash.start(0xffff00, 2);
|
||||
car.y = 0;
|
||||
}
|
||||
else if (car.y > myGame.world.height)
|
||||
{
|
||||
flash.start(0xff00ff, 3);
|
||||
car.y = myGame.world.height - car.height;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,41 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../build/phaser-fx.d.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
// Just set the world to be the size of the image we're loading in
|
||||
myGame.world.setSize(1216, 896);
|
||||
myGame.loader.addImageFile('backdrop', 'assets/pics/ninja-masters2.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var mirror;
|
||||
function create() {
|
||||
// What we need is a camera 800x400 pixels in size as the mirror effect will be 200px tall and sit below it.
|
||||
// So we resize our default camera to 400px
|
||||
myGame.camera.height = 400;
|
||||
// Because it's our default camera we need to tell it to disable clipping, otherwise we'll never see the mirror effect render.
|
||||
myGame.camera.disableClipping = true;
|
||||
// Add our effect to the camera
|
||||
mirror = myGame.camera.fx.add(Phaser.FX.Camera.Mirror);
|
||||
// The first 2 parameters are the x and y coordinates of where to display the effect. They are in STAGE coordinates, not World.
|
||||
// The next is a Quad making up the rectangular region of the Camera that we'll create the effect from (in this case the whole camera).
|
||||
// Finally we set the fill color that is put over the top of the mirror effect.
|
||||
mirror.start(0, 400, new Phaser.Quad(0, 0, 800, 400), 'rgba(0, 0, 100, 0.7)');
|
||||
// Experiment with variations on these to see the different mirror effects that can be achieved.
|
||||
//mirror.flipX = true;
|
||||
//mirror.flipY = true;
|
||||
myGame.add.sprite(0, 0, 'backdrop');
|
||||
}
|
||||
function update() {
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
myGame.camera.scroll.x -= 4;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
myGame.camera.scroll.x += 4;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
myGame.camera.scroll.y -= 4;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
myGame.camera.scroll.y += 4;
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,68 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../build/phaser-fx.d.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
// Just set the world to be the size of the image we're loading in
|
||||
myGame.world.setSize(1216, 896);
|
||||
|
||||
myGame.loader.addImageFile('backdrop', 'assets/pics/ninja-masters2.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var mirror: Phaser.FX.Camera.Mirror;
|
||||
|
||||
function create() {
|
||||
|
||||
// What we need is a camera 800x400 pixels in size as the mirror effect will be 200px tall and sit below it.
|
||||
// So we resize our default camera to 400px
|
||||
myGame.camera.height = 400;
|
||||
|
||||
// Because it's our default camera we need to tell it to disable clipping, otherwise we'll never see the mirror effect render.
|
||||
myGame.camera.disableClipping = true;
|
||||
|
||||
// Add our effect to the camera
|
||||
mirror = <Phaser.FX.Camera.Mirror> myGame.camera.fx.add(Phaser.FX.Camera.Mirror);
|
||||
|
||||
// The first 2 parameters are the x and y coordinates of where to display the effect. They are in STAGE coordinates, not World.
|
||||
// The next is a Quad making up the rectangular region of the Camera that we'll create the effect from (in this case the whole camera).
|
||||
// Finally we set the fill color that is put over the top of the mirror effect.
|
||||
mirror.start(0, 400, new Phaser.Quad(0, 0, 800, 400), 'rgba(0, 0, 100, 0.7)');
|
||||
|
||||
// Experiment with variations on these to see the different mirror effects that can be achieved.
|
||||
//mirror.flipX = true;
|
||||
//mirror.flipY = true;
|
||||
|
||||
myGame.add.sprite(0, 0, 'backdrop');
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
myGame.camera.scroll.x -= 4;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
myGame.camera.scroll.x += 4;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
myGame.camera.scroll.y -= 4;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
myGame.camera.scroll.y += 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,32 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../build/phaser-fx.d.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.world.setSize(1216, 896);
|
||||
myGame.loader.addImageFile('backdrop', 'assets/pics/ninja-masters2.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var scanlines;
|
||||
function create() {
|
||||
// Add our effect to the camera
|
||||
scanlines = myGame.camera.fx.add(Phaser.FX.Camera.Scanlines);
|
||||
// We'll have the scanlines spaced out every 2 pixels
|
||||
scanlines.spacing = 2;
|
||||
// This is the color the lines will be drawn in
|
||||
scanlines.color = 'rgba(0, 0, 0, 0.8)';
|
||||
myGame.add.sprite(0, 0, 'backdrop');
|
||||
}
|
||||
function update() {
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
myGame.camera.scroll.x -= 4;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
myGame.camera.scroll.x += 4;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
myGame.camera.scroll.y -= 4;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
myGame.camera.scroll.y += 4;
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,57 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../build/phaser-fx.d.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.world.setSize(1216, 896);
|
||||
|
||||
myGame.loader.addImageFile('backdrop', 'assets/pics/ninja-masters2.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var scanlines: Phaser.FX.Camera.Scanlines;
|
||||
|
||||
function create() {
|
||||
|
||||
// Add our effect to the camera
|
||||
scanlines = <Phaser.FX.Camera.Scanlines> myGame.camera.fx.add(Phaser.FX.Camera.Scanlines);
|
||||
|
||||
// We'll have the scanlines spaced out every 2 pixels
|
||||
scanlines.spacing = 2;
|
||||
|
||||
// This is the color the lines will be drawn in
|
||||
scanlines.color = 'rgba(0, 0, 0, 0.8)';
|
||||
|
||||
myGame.add.sprite(0, 0, 'backdrop');
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
myGame.camera.scroll.x -= 4;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
myGame.camera.scroll.x += 4;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
myGame.camera.scroll.y -= 4;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
myGame.camera.scroll.y += 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,50 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../build/phaser-fx.d.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('background', 'assets/pics/remember-me.jpg');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var car;
|
||||
var shake;
|
||||
function create() {
|
||||
myGame.add.sprite(0, 0, 'background');
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
// Add our effect to the camera
|
||||
shake = myGame.camera.fx.add(Phaser.FX.Camera.Shake);
|
||||
myGame.onRenderCallback = render;
|
||||
}
|
||||
function update() {
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 300));
|
||||
}
|
||||
// Shake the camera when the car hits the edges, a different intensity per edge
|
||||
if(car.x < 0) {
|
||||
shake.start();
|
||||
car.x = 0;
|
||||
} else if(car.x > myGame.world.width) {
|
||||
shake.start(0.02);
|
||||
car.x = myGame.world.width - car.width;
|
||||
}
|
||||
if(car.y < 0) {
|
||||
shake.start(0.07, 1);
|
||||
car.y = 0;
|
||||
} else if(car.y > myGame.world.height) {
|
||||
shake.start(0.1);
|
||||
car.y = myGame.world.height - car.height;
|
||||
}
|
||||
}
|
||||
function render() {
|
||||
myGame.camera.renderDebugInfo(32, 32);
|
||||
}
|
||||
})();
|
|
@ -1,85 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../build/phaser-fx.d.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.loader.addImageFile('background', 'assets/pics/remember-me.jpg');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var car: Phaser.Sprite;
|
||||
var shake: Phaser.FX.Camera.Shake;
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.add.sprite(0, 0, 'background');
|
||||
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
|
||||
// Add our effect to the camera
|
||||
shake = <Phaser.FX.Camera.Shake> myGame.camera.fx.add(Phaser.FX.Camera.Shake);
|
||||
|
||||
myGame.onRenderCallback = render;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 300));
|
||||
}
|
||||
|
||||
// Shake the camera when the car hits the edges, a different intensity per edge
|
||||
|
||||
if (car.x < 0)
|
||||
{
|
||||
shake.start();
|
||||
car.x = 0;
|
||||
}
|
||||
else if (car.x > myGame.world.width)
|
||||
{
|
||||
shake.start(0.02);
|
||||
car.x = myGame.world.width - car.width;
|
||||
}
|
||||
|
||||
if (car.y < 0)
|
||||
{
|
||||
shake.start(0.07, 1);
|
||||
car.y = 0;
|
||||
}
|
||||
else if (car.y > myGame.world.height)
|
||||
{
|
||||
shake.start(0.1);
|
||||
car.y = myGame.world.height - car.height;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
myGame.camera.renderDebugInfo(32, 32);
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,38 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.world.setSize(2240, 2240);
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var car;
|
||||
var miniCam;
|
||||
function create() {
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
myGame.camera.follow(car, Phaser.Camera.STYLE_TOPDOWN);
|
||||
myGame.camera.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
miniCam = myGame.add.camera(0, 0, 300, 300);
|
||||
miniCam.follow(car, Phaser.Camera.STYLE_TOPDOWN_TIGHT);
|
||||
miniCam.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
miniCam.showBorder = true;
|
||||
miniCam.alpha = 0.7;
|
||||
}
|
||||
function update() {
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
var motion = myGame.motion.velocityFromAngle(car.angle, 300);
|
||||
car.velocity.copyFrom(motion);
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,63 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.world.setSize(2240, 2240);
|
||||
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var car: Phaser.Sprite;
|
||||
var miniCam: Phaser.Camera;
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
|
||||
myGame.camera.follow(car, Phaser.Camera.STYLE_TOPDOWN);
|
||||
myGame.camera.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
|
||||
miniCam = myGame.add.camera(0, 0, 300, 300);
|
||||
miniCam.follow(car, Phaser.Camera.STYLE_TOPDOWN_TIGHT);
|
||||
miniCam.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
miniCam.showBorder = true;
|
||||
miniCam.alpha = 0.7;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
var motion:Phaser.Point = myGame.motion.velocityFromAngle(car.angle, 300);
|
||||
|
||||
car.velocity.copyFrom(motion);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,33 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.world.setSize(1920, 1200);
|
||||
myGame.camera.setBounds(0, 0, 1920, 1200);
|
||||
myGame.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg');
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
function create() {
|
||||
myGame.add.sprite(0, 0, 'backdrop');
|
||||
for(var i = 0; i < 100; i++) {
|
||||
myGame.add.sprite(Math.random() * myGame.world.width, Math.random() * myGame.world.height, 'melon');
|
||||
}
|
||||
myGame.onRenderCallback = render;
|
||||
}
|
||||
function update() {
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
myGame.camera.scroll.x -= 4;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
myGame.camera.scroll.x += 4;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
myGame.camera.scroll.y -= 4;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
myGame.camera.scroll.y += 4;
|
||||
}
|
||||
}
|
||||
function render() {
|
||||
myGame.camera.renderDebugInfo(32, 32);
|
||||
}
|
||||
})();
|
|
@ -1,60 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.world.setSize(1920, 1200);
|
||||
myGame.camera.setBounds(0, 0, 1920, 1200);
|
||||
|
||||
myGame.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg');
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.add.sprite(0, 0, 'backdrop');
|
||||
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
myGame.add.sprite(Math.random() * myGame.world.width, Math.random() * myGame.world.height, 'melon');
|
||||
}
|
||||
|
||||
myGame.onRenderCallback = render;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
myGame.camera.scroll.x -= 4;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
myGame.camera.scroll.x += 4;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
myGame.camera.scroll.y -= 4;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
myGame.camera.scroll.y += 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
myGame.camera.renderDebugInfo(32, 32);
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,40 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.world.setSize(3000, 3000);
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var cam2;
|
||||
function create() {
|
||||
for(var i = 0; i < 1000; i++) {
|
||||
myGame.add.sprite(Math.random() * 3000, Math.random() * 3000, 'melon');
|
||||
}
|
||||
myGame.camera.setPosition(16, 80);
|
||||
myGame.camera.setSize(320, 320);
|
||||
myGame.camera.showBorder = true;
|
||||
myGame.camera.borderColor = 'rgb(255,0,0)';
|
||||
cam2 = myGame.add.camera(380, 100, 400, 400);
|
||||
cam2.showBorder = true;
|
||||
cam2.borderColor = 'rgb(255,255,0)';
|
||||
}
|
||||
function update() {
|
||||
myGame.camera.renderDebugInfo(16, 16);
|
||||
cam2.renderDebugInfo(200, 16);
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
myGame.camera.x -= 4;
|
||||
cam2.x -= 2;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
myGame.camera.x += 4;
|
||||
cam2.x += 2;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
myGame.camera.y -= 4;
|
||||
cam2.y -= 2;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
myGame.camera.y += 4;
|
||||
cam2.y += 2;
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,66 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.world.setSize(3000, 3000);
|
||||
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var cam2: Phaser.Camera;
|
||||
|
||||
function create() {
|
||||
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
myGame.add.sprite(Math.random() * 3000, Math.random() * 3000, 'melon');
|
||||
}
|
||||
|
||||
myGame.camera.setPosition(16, 80);
|
||||
myGame.camera.setSize(320, 320);
|
||||
myGame.camera.showBorder = true;
|
||||
myGame.camera.borderColor = 'rgb(255,0,0)';
|
||||
|
||||
cam2 = myGame.add.camera(380, 100, 400, 400);
|
||||
cam2.showBorder = true;
|
||||
cam2.borderColor = 'rgb(255,255,0)';
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
myGame.camera.renderDebugInfo(16, 16);
|
||||
cam2.renderDebugInfo(200, 16);
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
myGame.camera.x -= 4;
|
||||
cam2.x -= 2;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
myGame.camera.x += 4;
|
||||
cam2.x += 2;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
myGame.camera.y -= 4;
|
||||
cam2.y -= 2;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
myGame.camera.y += 4;
|
||||
cam2.y += 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,34 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.world.setSize(3000, 3000);
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car.png');
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
function create() {
|
||||
for(var i = 0; i < 1000; i++) {
|
||||
if(Math.random() > 0.5) {
|
||||
myGame.add.sprite(Math.random() * 3000, Math.random() * 3000, 'car');
|
||||
} else {
|
||||
myGame.add.sprite(Math.random() * 3000, Math.random() * 3000, 'melon');
|
||||
}
|
||||
}
|
||||
myGame.camera.setPosition(100, 100);
|
||||
myGame.camera.setSize(320, 320);
|
||||
}
|
||||
function update() {
|
||||
myGame.camera.renderDebugInfo(600, 32);
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
myGame.camera.rotation -= 2;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
myGame.camera.rotation += 2;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
myGame.camera.scroll.y -= 4;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
myGame.camera.scroll.y += 4;
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,61 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.world.setSize(3000, 3000);
|
||||
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car.png');
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
if (Math.random() > 0.5)
|
||||
{
|
||||
myGame.add.sprite(Math.random() * 3000, Math.random() * 3000, 'car');
|
||||
}
|
||||
else
|
||||
{
|
||||
myGame.add.sprite(Math.random() * 3000, Math.random() * 3000, 'melon');
|
||||
}
|
||||
}
|
||||
|
||||
myGame.camera.setPosition(100, 100);
|
||||
myGame.camera.setSize(320, 320);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
myGame.camera.renderDebugInfo(600, 32);
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
myGame.camera.rotation -= 2;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
myGame.camera.rotation += 2;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
myGame.camera.scroll.y -= 4;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
myGame.camera.scroll.y += 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,45 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.world.setSize(2240, 2240);
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var car;
|
||||
var miniCam;
|
||||
var bigCam;
|
||||
function create() {
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
myGame.camera.follow(car);
|
||||
myGame.camera.deadzone = new Phaser.Rectangle(64, 64, myGame.stage.width - 128, myGame.stage.height - 128);
|
||||
myGame.camera.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
miniCam = myGame.add.camera(600, 32, 200, 200);
|
||||
miniCam.follow(car, Phaser.Camera.STYLE_LOCKON);
|
||||
miniCam.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
miniCam.showBorder = true;
|
||||
miniCam.scale.setTo(0.5, 0.5);
|
||||
bigCam = myGame.add.camera(32, 32, 200, 200);
|
||||
bigCam.follow(car, Phaser.Camera.STYLE_LOCKON);
|
||||
bigCam.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
bigCam.showBorder = true;
|
||||
bigCam.scale.setTo(2, 2);
|
||||
}
|
||||
function update() {
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
var motion = myGame.motion.velocityFromAngle(car.angle, 300);
|
||||
car.velocity.copyFrom(motion);
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,71 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.world.setSize(2240, 2240);
|
||||
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var car: Phaser.Sprite;
|
||||
var miniCam: Phaser.Camera;
|
||||
var bigCam: Phaser.Camera;
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
|
||||
myGame.camera.follow(car);
|
||||
myGame.camera.deadzone = new Phaser.Rectangle(64, 64, myGame.stage.width - 128, myGame.stage.height - 128);
|
||||
myGame.camera.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
|
||||
miniCam = myGame.add.camera(600, 32, 200, 200);
|
||||
miniCam.follow(car, Phaser.Camera.STYLE_LOCKON);
|
||||
miniCam.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
miniCam.showBorder = true;
|
||||
miniCam.scale.setTo(0.5, 0.5);
|
||||
|
||||
bigCam = myGame.add.camera(32, 32, 200, 200);
|
||||
bigCam.follow(car, Phaser.Camera.STYLE_LOCKON);
|
||||
bigCam.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
bigCam.showBorder = true;
|
||||
bigCam.scale.setTo(2, 2);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
var motion:Phaser.Point = myGame.motion.velocityFromAngle(car.angle, 300);
|
||||
|
||||
car.velocity.copyFrom(motion);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,47 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.world.setSize(2240, 2240);
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var car;
|
||||
var miniCam;
|
||||
var bigCam;
|
||||
function create() {
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
myGame.camera.follow(car);
|
||||
myGame.camera.deadzone = new Phaser.Rectangle(64, 64, myGame.stage.width - 128, myGame.stage.height - 128);
|
||||
myGame.camera.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
miniCam = myGame.add.camera(600, 32, 200, 200);
|
||||
miniCam.follow(car, Phaser.Camera.STYLE_LOCKON);
|
||||
miniCam.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
miniCam.showBorder = true;
|
||||
miniCam.scale.setTo(0.5, 0.5);
|
||||
miniCam.showShadow = true;
|
||||
bigCam = myGame.add.camera(32, 32, 200, 200);
|
||||
bigCam.follow(car, Phaser.Camera.STYLE_LOCKON);
|
||||
bigCam.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
bigCam.showBorder = true;
|
||||
bigCam.scale.setTo(2, 2);
|
||||
bigCam.showShadow = true;
|
||||
}
|
||||
function update() {
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
var motion = myGame.motion.velocityFromAngle(car.angle, 300);
|
||||
car.velocity.copyFrom(motion);
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,73 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.world.setSize(2240, 2240);
|
||||
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var car: Phaser.Sprite;
|
||||
var miniCam: Phaser.Camera;
|
||||
var bigCam: Phaser.Camera;
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
|
||||
myGame.camera.follow(car);
|
||||
myGame.camera.deadzone = new Phaser.Rectangle(64, 64, myGame.stage.width - 128, myGame.stage.height - 128);
|
||||
myGame.camera.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
|
||||
miniCam = myGame.add.camera(600, 32, 200, 200);
|
||||
miniCam.follow(car, Phaser.Camera.STYLE_LOCKON);
|
||||
miniCam.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
miniCam.showBorder = true;
|
||||
miniCam.scale.setTo(0.5, 0.5);
|
||||
miniCam.showShadow = true;
|
||||
|
||||
bigCam = myGame.add.camera(32, 32, 200, 200);
|
||||
bigCam.follow(car, Phaser.Camera.STYLE_LOCKON);
|
||||
bigCam.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
bigCam.showBorder = true;
|
||||
bigCam.scale.setTo(2, 2);
|
||||
bigCam.showShadow = true;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
var motion:Phaser.Point = myGame.motion.velocityFromAngle(car.angle, 300);
|
||||
|
||||
car.velocity.copyFrom(motion);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,46 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.world.setSize(2240, 2240);
|
||||
myGame.loader.addImageFile('balls', 'assets/sprites/balls.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var car;
|
||||
var miniCam;
|
||||
var bigCam;
|
||||
function create() {
|
||||
//myGame.add.sprite('grid', 0, 0);
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
myGame.camera.setTexture('balls');
|
||||
myGame.camera.follow(car);
|
||||
myGame.camera.deadzone = new Phaser.Rectangle(64, 64, myGame.stage.width - 128, myGame.stage.height - 128);
|
||||
myGame.camera.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
//miniCam = myGame.add.camera(600, 32, 200, 200);
|
||||
//miniCam.follow(car, Camera.STYLE_LOCKON);
|
||||
//miniCam.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
//miniCam.showBorder = true;
|
||||
//miniCam.scale.setTo(0.5, 0.5);
|
||||
//bigCam = myGame.add.camera(32, 32, 200, 200);
|
||||
//bigCam.follow(car, Camera.STYLE_LOCKON);
|
||||
//bigCam.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
//bigCam.showBorder = true;
|
||||
//bigCam.scale.setTo(2, 2);
|
||||
}
|
||||
function update() {
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
var motion = myGame.motion.velocityFromAngle(car.angle, 300);
|
||||
car.velocity.copyFrom(motion);
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,72 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.world.setSize(2240, 2240);
|
||||
|
||||
myGame.loader.addImageFile('balls', 'assets/sprites/balls.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var car: Phaser.Sprite;
|
||||
var miniCam: Phaser.Camera;
|
||||
var bigCam: Phaser.Camera;
|
||||
|
||||
function create() {
|
||||
|
||||
//myGame.add.sprite('grid', 0, 0);
|
||||
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
|
||||
myGame.camera.setTexture('balls');
|
||||
myGame.camera.follow(car);
|
||||
myGame.camera.deadzone = new Phaser.Rectangle(64, 64, myGame.stage.width - 128, myGame.stage.height - 128);
|
||||
myGame.camera.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
|
||||
//miniCam = myGame.add.camera(600, 32, 200, 200);
|
||||
//miniCam.follow(car, Camera.STYLE_LOCKON);
|
||||
//miniCam.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
//miniCam.showBorder = true;
|
||||
//miniCam.scale.setTo(0.5, 0.5);
|
||||
|
||||
//bigCam = myGame.add.camera(32, 32, 200, 200);
|
||||
//bigCam.follow(car, Camera.STYLE_LOCKON);
|
||||
//bigCam.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
//bigCam.showBorder = true;
|
||||
//bigCam.scale.setTo(2, 2);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
var motion:Phaser.Point = myGame.motion.velocityFromAngle(car.angle, 300);
|
||||
|
||||
car.velocity.copyFrom(motion);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,36 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.world.setSize(1920, 1920);
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
myGame.loader.addImageFile('carrot', 'assets/sprites/carrot.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var melon;
|
||||
function create() {
|
||||
// locked to the camera
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
melon = myGame.add.sprite(600, 650, 'melon');
|
||||
melon.scrollFactor.setTo(1.5, 1.5);
|
||||
// scrolls x2 camera speed
|
||||
for(var i = 0; i < 100; i++) {
|
||||
var tempSprite = myGame.add.sprite(Math.random() * myGame.world.width, Math.random() * myGame.world.height, 'carrot');
|
||||
tempSprite.scrollFactor.setTo(2, 2);
|
||||
}
|
||||
}
|
||||
function update() {
|
||||
myGame.camera.renderDebugInfo(32, 32);
|
||||
melon.renderDebugInfo(200, 32);
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
myGame.camera.focusOnXY(640, 640);
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
myGame.camera.focusOnXY(1234, 800);
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
myGame.camera.focusOnXY(50, 200);
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
myGame.camera.focusOnXY(1700, 1700);
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,62 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.world.setSize(1920, 1920);
|
||||
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
myGame.loader.addImageFile('carrot', 'assets/sprites/carrot.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var melon: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
// locked to the camera
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
|
||||
melon = myGame.add.sprite(600, 650, 'melon');
|
||||
melon.scrollFactor.setTo(1.5, 1.5);
|
||||
|
||||
// scrolls x2 camera speed
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var tempSprite = myGame.add.sprite(Math.random() * myGame.world.width, Math.random() * myGame.world.height, 'carrot');
|
||||
tempSprite.scrollFactor.setTo(2, 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
myGame.camera.renderDebugInfo(32, 32);
|
||||
melon.renderDebugInfo(200, 32);
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
myGame.camera.focusOnXY(640, 640);
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
myGame.camera.focusOnXY(1234, 800);
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
myGame.camera.focusOnXY(50, 200);
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
myGame.camera.focusOnXY(1700, 1700);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,36 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.world.setSize(2240, 2240);
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var car;
|
||||
function create() {
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
myGame.camera.follow(car);
|
||||
// Here we'll set our own custom deadzone which is 64px smaller than the stage size on all sides
|
||||
myGame.camera.deadzone = new Phaser.Rectangle(64, 64, myGame.stage.width - 128, myGame.stage.height - 128);
|
||||
myGame.camera.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
}
|
||||
function update() {
|
||||
myGame.camera.renderDebugInfo(32, 32);
|
||||
car.renderDebugInfo(200, 32);
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
var motion = myGame.motion.velocityFromAngle(car.angle, 300);
|
||||
car.velocity.copyFrom(motion);
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,61 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.world.setSize(2240, 2240);
|
||||
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var car: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
|
||||
myGame.camera.follow(car);
|
||||
// Here we'll set our own custom deadzone which is 64px smaller than the stage size on all sides
|
||||
myGame.camera.deadzone = new Phaser.Rectangle(64, 64, myGame.stage.width - 128, myGame.stage.height - 128);
|
||||
myGame.camera.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
myGame.camera.renderDebugInfo(32, 32);
|
||||
car.renderDebugInfo(200, 32);
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
var motion:Phaser.Point = myGame.motion.velocityFromAngle(car.angle, 300);
|
||||
|
||||
car.velocity.copyFrom(motion);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,34 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.world.setSize(1920, 1920);
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var car;
|
||||
function create() {
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
myGame.camera.follow(car);
|
||||
myGame.onRenderCallback = render;
|
||||
}
|
||||
function update() {
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 300));
|
||||
}
|
||||
}
|
||||
function render() {
|
||||
myGame.camera.renderDebugInfo(32, 32);
|
||||
car.renderDebugInfo(200, 32);
|
||||
}
|
||||
})();
|
|
@ -1,62 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.world.setSize(1920, 1920);
|
||||
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var car;
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
|
||||
myGame.camera.follow(car);
|
||||
|
||||
myGame.onRenderCallback = render;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 300));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
myGame.camera.renderDebugInfo(32, 32);
|
||||
car.renderDebugInfo(200, 32);
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,34 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.world.setSize(2240, 2240);
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var car;
|
||||
function create() {
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
myGame.camera.follow(car, Phaser.Camera.STYLE_TOPDOWN);
|
||||
myGame.camera.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
}
|
||||
function update() {
|
||||
myGame.camera.renderDebugInfo(32, 32);
|
||||
car.renderDebugInfo(200, 32);
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
var motion = myGame.motion.velocityFromAngle(car.angle, 300);
|
||||
car.velocity.copyFrom(motion);
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,59 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.world.setSize(2240, 2240);
|
||||
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var car: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
|
||||
myGame.camera.follow(car, Phaser.Camera.STYLE_TOPDOWN);
|
||||
myGame.camera.setBounds(0, 0, myGame.world.width, myGame.world.height);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
myGame.camera.renderDebugInfo(32, 32);
|
||||
car.renderDebugInfo(200, 32);
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
var motion:Phaser.Point = myGame.motion.velocityFromAngle(car.angle, 300);
|
||||
|
||||
car.velocity.copyFrom(motion);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,44 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.world.setSize(3000, 3000);
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car.png');
|
||||
myGame.loader.addImageFile('coin', 'assets/sprites/coin.png');
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var cam2;
|
||||
function create() {
|
||||
for(var i = 0; i < 1000; i++) {
|
||||
myGame.add.sprite(Math.random() * 3000, Math.random() * 3000, 'melon');
|
||||
}
|
||||
myGame.camera.setPosition(16, 80);
|
||||
myGame.camera.setSize(320, 320);
|
||||
myGame.camera.showBorder = true;
|
||||
myGame.camera.borderColor = 'rgb(255,0,0)';
|
||||
cam2 = myGame.add.camera(380, 100, 400, 400);
|
||||
//cam2.transparent = false;
|
||||
//cam2.backgroundColor = 'rgb(20,20,20)';
|
||||
cam2.showBorder = true;
|
||||
cam2.borderColor = 'rgb(255,255,0)';
|
||||
}
|
||||
function update() {
|
||||
myGame.camera.renderDebugInfo(16, 16);
|
||||
cam2.renderDebugInfo(200, 16);
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
myGame.camera.scroll.x -= 4;
|
||||
cam2.scroll.x -= 2;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
myGame.camera.scroll.x += 4;
|
||||
cam2.scroll.x += 2;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
myGame.camera.scroll.y -= 4;
|
||||
cam2.scroll.y -= 2;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
myGame.camera.scroll.y += 4;
|
||||
cam2.scroll.y += 2;
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,70 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.world.setSize(3000, 3000);
|
||||
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car.png');
|
||||
myGame.loader.addImageFile('coin', 'assets/sprites/coin.png');
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var cam2: Phaser.Camera;
|
||||
|
||||
function create() {
|
||||
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
myGame.add.sprite(Math.random() * 3000, Math.random() * 3000, 'melon');
|
||||
}
|
||||
|
||||
myGame.camera.setPosition(16, 80);
|
||||
myGame.camera.setSize(320, 320);
|
||||
myGame.camera.showBorder = true;
|
||||
myGame.camera.borderColor = 'rgb(255,0,0)';
|
||||
|
||||
cam2 = myGame.add.camera(380, 100, 400, 400);
|
||||
//cam2.transparent = false;
|
||||
//cam2.backgroundColor = 'rgb(20,20,20)';
|
||||
cam2.showBorder = true;
|
||||
cam2.borderColor = 'rgb(255,255,0)';
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
myGame.camera.renderDebugInfo(16, 16);
|
||||
cam2.renderDebugInfo(200, 16);
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
myGame.camera.scroll.x -= 4;
|
||||
cam2.scroll.x -= 2;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
myGame.camera.scroll.x += 4;
|
||||
cam2.scroll.x += 2;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
myGame.camera.scroll.y -= 4;
|
||||
cam2.scroll.y -= 2;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
myGame.camera.scroll.y += 4;
|
||||
cam2.scroll.y += 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,37 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.world.setSize(1920, 1200);
|
||||
myGame.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg');
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
myGame.loader.addImageFile('carrot', 'assets/sprites/carrot.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var melon;
|
||||
function create() {
|
||||
// scrolls in time with the camera
|
||||
myGame.add.sprite(0, 0, 'backdrop');
|
||||
melon = myGame.add.sprite(600, 650, 'melon');
|
||||
melon.scrollFactor.setTo(1.5, 1.5);
|
||||
// scrolls x2 camera speed
|
||||
for(var i = 0; i < 100; i++) {
|
||||
var tempSprite = myGame.add.sprite(Math.random() * myGame.world.width, Math.random() * myGame.world.height, 'carrot');
|
||||
tempSprite.scrollFactor.setTo(2, 2);
|
||||
}
|
||||
}
|
||||
function update() {
|
||||
myGame.camera.renderDebugInfo(32, 32);
|
||||
melon.renderDebugInfo(200, 32);
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
myGame.camera.scroll.x -= 1;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
myGame.camera.scroll.x += 1;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
myGame.camera.scroll.y -= 1;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
myGame.camera.scroll.y += 1;
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,63 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.world.setSize(1920, 1200);
|
||||
|
||||
myGame.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg');
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
myGame.loader.addImageFile('carrot', 'assets/sprites/carrot.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var melon: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
// scrolls in time with the camera
|
||||
myGame.add.sprite(0, 0, 'backdrop');
|
||||
|
||||
melon = myGame.add.sprite(600, 650, 'melon');
|
||||
melon.scrollFactor.setTo(1.5, 1.5);
|
||||
|
||||
// scrolls x2 camera speed
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var tempSprite = myGame.add.sprite(Math.random() * myGame.world.width, Math.random() * myGame.world.height, 'carrot');
|
||||
tempSprite.scrollFactor.setTo(2, 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
myGame.camera.renderDebugInfo(32, 32);
|
||||
melon.renderDebugInfo(200, 32);
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
myGame.camera.scroll.x -= 1;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
myGame.camera.scroll.x += 1;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
myGame.camera.scroll.y -= 1;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
myGame.camera.scroll.y += 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,35 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var car;
|
||||
var melon;
|
||||
function create() {
|
||||
car = myGame.add.sprite(100, 300, 'car');
|
||||
melon = myGame.add.sprite(200, 310, 'melon');
|
||||
car.name = 'car';
|
||||
melon.name = 'melon';
|
||||
}
|
||||
function update() {
|
||||
car.renderDebugInfo(16, 16);
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 200));
|
||||
}
|
||||
myGame.collide(car, melon, collides);
|
||||
}
|
||||
function collides(a, b) {
|
||||
console.log('Collision!!!!!');
|
||||
}
|
||||
})();
|
|
@ -1,61 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var car: Phaser.Sprite;
|
||||
var melon: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
car = myGame.add.sprite(100, 300, 'car');
|
||||
melon = myGame.add.sprite(200, 310, 'melon');
|
||||
|
||||
car.name = 'car';
|
||||
melon.name = 'melon';
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
car.renderDebugInfo(16, 16);
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 200));
|
||||
}
|
||||
|
||||
myGame.collide(car, melon, collides);
|
||||
|
||||
}
|
||||
|
||||
function collides(a, b) {
|
||||
|
||||
console.log('Collision!!!!!');
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,45 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('ball0', 'assets/sprites/yellow_ball.png');
|
||||
myGame.loader.addImageFile('ball1', 'assets/sprites/aqua_ball.png');
|
||||
myGame.loader.addImageFile('ball2', 'assets/sprites/blue_ball.png');
|
||||
myGame.loader.addImageFile('ball3', 'assets/sprites/green_ball.png');
|
||||
myGame.loader.addImageFile('ball4', 'assets/sprites/red_ball.png');
|
||||
myGame.loader.addImageFile('ball5', 'assets/sprites/purple_ball.png');
|
||||
myGame.loader.addImageFile('atari', 'assets/sprites/atari130xe.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var atari;
|
||||
var balls;
|
||||
function create() {
|
||||
atari = myGame.add.sprite(300, 450, 'atari');
|
||||
atari.immovable = true;
|
||||
balls = myGame.add.group();
|
||||
for(var i = 0; i < 100; i++) {
|
||||
var tempBall = new Phaser.Sprite(myGame, Math.random() * myGame.stage.width, -32, 'ball' + Math.round(Math.random() * 5));
|
||||
tempBall.velocity.y = 100 + Math.random() * 150;
|
||||
tempBall.elasticity = 0.9;
|
||||
balls.add(tempBall);
|
||||
}
|
||||
}
|
||||
function update() {
|
||||
atari.velocity.x = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
atari.velocity.x = -400;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
atari.velocity.x = 400;
|
||||
}
|
||||
balls.forEach(checkOffScreen, false);
|
||||
myGame.collide(atari, balls);
|
||||
}
|
||||
function checkOffScreen(ball) {
|
||||
if(ball.y < -32 || ball.y > myGame.stage.height || ball.x < 0 || ball.x > myGame.stage.width) {
|
||||
ball.x = Math.random() * myGame.stage.width;
|
||||
ball.y = -32;
|
||||
ball.velocity.x = 0;
|
||||
ball.velocity.y = 100 + Math.random() * 150;
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,72 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.loader.addImageFile('ball0', 'assets/sprites/yellow_ball.png');
|
||||
myGame.loader.addImageFile('ball1', 'assets/sprites/aqua_ball.png');
|
||||
myGame.loader.addImageFile('ball2', 'assets/sprites/blue_ball.png');
|
||||
myGame.loader.addImageFile('ball3', 'assets/sprites/green_ball.png');
|
||||
myGame.loader.addImageFile('ball4', 'assets/sprites/red_ball.png');
|
||||
myGame.loader.addImageFile('ball5', 'assets/sprites/purple_ball.png');
|
||||
myGame.loader.addImageFile('atari', 'assets/sprites/atari130xe.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var atari: Phaser.Sprite;
|
||||
var balls: Phaser.Group;
|
||||
|
||||
function create() {
|
||||
|
||||
atari = myGame.add.sprite(300, 450, 'atari');
|
||||
atari.immovable = true;
|
||||
|
||||
balls = myGame.add.group();
|
||||
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var tempBall: Phaser.Sprite = new Phaser.Sprite(myGame, Math.random() * myGame.stage.width, -32, 'ball' + Math.round(Math.random() * 5));
|
||||
tempBall.velocity.y = 100 + Math.random() * 150;
|
||||
tempBall.elasticity = 0.9;
|
||||
balls.add(tempBall);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
atari.velocity.x = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
atari.velocity.x = -400;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
atari.velocity.x = 400;
|
||||
}
|
||||
|
||||
balls.forEach(checkOffScreen, false);
|
||||
|
||||
myGame.collide(atari, balls);
|
||||
|
||||
}
|
||||
|
||||
function checkOffScreen(ball:Phaser.Sprite) {
|
||||
|
||||
if (ball.y < -32 || ball.y > myGame.stage.height || ball.x < 0 || ball.x > myGame.stage.width)
|
||||
{
|
||||
ball.x = Math.random() * myGame.stage.width;
|
||||
ball.y = -32;
|
||||
ball.velocity.x = 0;
|
||||
ball.velocity.y = 100 + Math.random() * 150;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,31 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('card', 'assets/sprites/mana_card.png');
|
||||
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var card;
|
||||
var bot;
|
||||
function create() {
|
||||
card = myGame.add.sprite(200, 220, 'card');
|
||||
bot = myGame.add.sprite(myGame.stage.width - 100, 300, 'bot');
|
||||
// The collision mask is much thinner than the animated sprite
|
||||
bot.collisionMask.offset.x = 16;
|
||||
bot.collisionMask.width = 32;
|
||||
bot.renderDebug = true;
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
bot.velocity.x = -150;
|
||||
}
|
||||
function update() {
|
||||
if(bot.x < -bot.width) {
|
||||
bot.x = myGame.stage.width;
|
||||
bot.velocity.x = -150;
|
||||
card.x = 200;
|
||||
card.velocity.x = 0;
|
||||
}
|
||||
myGame.collide(card, bot);
|
||||
}
|
||||
})();
|
|
@ -1,50 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.loader.addImageFile('card', 'assets/sprites/mana_card.png');
|
||||
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var card: Phaser.Sprite;
|
||||
var bot: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
card = myGame.add.sprite(200, 220, 'card');
|
||||
|
||||
bot = myGame.add.sprite(myGame.stage.width - 100, 300, 'bot');
|
||||
|
||||
// The collision mask is much thinner than the animated sprite
|
||||
bot.collisionMask.offset.x = 16;
|
||||
bot.collisionMask.width = 32;
|
||||
bot.renderDebug = true;
|
||||
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
|
||||
bot.velocity.x = -150;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (bot.x < -bot.width)
|
||||
{
|
||||
bot.x = myGame.stage.width;
|
||||
bot.velocity.x = -150;
|
||||
card.x = 200;
|
||||
card.velocity.x = 0;
|
||||
}
|
||||
|
||||
myGame.collide(card, bot);
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,38 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
|
||||
myGame.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var atari1;
|
||||
var atari2;
|
||||
var atari3;
|
||||
function create() {
|
||||
atari1 = myGame.add.sprite(270, 100, 'atari1');
|
||||
atari2 = myGame.add.sprite(400, 400, 'atari2');
|
||||
atari3 = myGame.add.sprite(0, 440, 'atari1');
|
||||
atari1.collisionMask.height = 16;
|
||||
atari3.collisionMask.width = 16;
|
||||
atari1.elasticity = 0.5;
|
||||
atari3.elasticity = 0.5;
|
||||
atari2.immovable = true;
|
||||
atari1.renderDebug = true;
|
||||
atari2.renderDebug = true;
|
||||
atari3.renderDebug = true;
|
||||
myGame.input.onTap.addOnce(startDrop, this);
|
||||
}
|
||||
function startDrop() {
|
||||
atari1.velocity.y = 100;
|
||||
atari3.velocity.x = 100;
|
||||
}
|
||||
function update() {
|
||||
myGame.collide(myGame.world.group);
|
||||
}
|
||||
function collides(a, b) {
|
||||
console.log('Collision!!!!!');
|
||||
}
|
||||
function render() {
|
||||
}
|
||||
})();
|
|
@ -1,64 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
|
||||
myGame.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var atari1: Phaser.Sprite;
|
||||
var atari2: Phaser.Sprite;
|
||||
var atari3: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
atari1 = myGame.add.sprite(270, 100, 'atari1');
|
||||
atari2 = myGame.add.sprite(400, 400, 'atari2');
|
||||
atari3 = myGame.add.sprite(0, 440, 'atari1');
|
||||
|
||||
atari1.collisionMask.height = 16;
|
||||
atari3.collisionMask.width = 16;
|
||||
|
||||
atari1.elasticity = 0.5;
|
||||
atari3.elasticity = 0.5;
|
||||
|
||||
atari2.immovable = true;
|
||||
|
||||
atari1.renderDebug = true;
|
||||
atari2.renderDebug = true;
|
||||
atari3.renderDebug = true;
|
||||
|
||||
myGame.input.onTap.addOnce(startDrop, this);
|
||||
|
||||
}
|
||||
|
||||
function startDrop() {
|
||||
|
||||
atari1.velocity.y = 100;
|
||||
atari3.velocity.x = 100;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
myGame.collide(myGame.world.group);
|
||||
|
||||
}
|
||||
|
||||
function collides(a, b) {
|
||||
|
||||
console.log('Collision!!!!!');
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,35 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
|
||||
myGame.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var atari1;
|
||||
var atari2;
|
||||
function create() {
|
||||
atari1 = myGame.add.sprite(400, 100, 'atari1');
|
||||
atari2 = myGame.add.sprite(400, 400, 'atari2');
|
||||
//atari1.collisionMask.createCircle(64);
|
||||
//atari1.rotation = 45;
|
||||
atari1.elasticity = 0.5;
|
||||
//atari2.collisionMask.createCircle(64);
|
||||
atari2.immovable = true;
|
||||
atari1.renderDebug = true;
|
||||
atari2.renderDebug = true;
|
||||
myGame.input.onTap.addOnce(startDrop, this);
|
||||
}
|
||||
function startDrop() {
|
||||
atari1.velocity.y = 100;
|
||||
}
|
||||
function update() {
|
||||
myGame.collide(myGame.world.group);
|
||||
}
|
||||
function collides(a, b) {
|
||||
console.log('Collision!!!!!');
|
||||
}
|
||||
function render() {
|
||||
//atari1.ren
|
||||
}
|
||||
})();
|
|
@ -1,62 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
|
||||
myGame.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var atari1: Phaser.Sprite;
|
||||
var atari2: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
atari1 = myGame.add.sprite(400, 100, 'atari1');
|
||||
atari2 = myGame.add.sprite(400, 400, 'atari2');
|
||||
|
||||
//atari1.collisionMask.createCircle(64);
|
||||
//atari1.rotation = 45;
|
||||
atari1.elasticity = 0.5;
|
||||
|
||||
//atari2.collisionMask.createCircle(64);
|
||||
atari2.immovable = true;
|
||||
|
||||
atari1.renderDebug = true;
|
||||
atari2.renderDebug = true;
|
||||
|
||||
myGame.input.onTap.addOnce(startDrop, this);
|
||||
|
||||
}
|
||||
|
||||
function startDrop() {
|
||||
|
||||
atari1.velocity.y = 100;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
myGame.collide(myGame.world.group);
|
||||
|
||||
}
|
||||
|
||||
function collides(a, b) {
|
||||
|
||||
console.log('Collision!!!!!');
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
//atari1.ren
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,19 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update);
|
||||
var circle;
|
||||
var floor;
|
||||
function create() {
|
||||
circle = myGame.add.geomSprite(200, 0);
|
||||
circle.createCircle(64);
|
||||
circle.acceleration.y = 100;
|
||||
circle.elasticity = 0.8;
|
||||
// A simple floor
|
||||
floor = myGame.add.geomSprite(0, 550);
|
||||
floor.createRectangle(800, 50);
|
||||
floor.immovable = true;
|
||||
}
|
||||
function update() {
|
||||
myGame.collide(circle, floor);
|
||||
}
|
||||
})();
|
|
@ -1,30 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update);
|
||||
|
||||
var circle: Phaser.GeomSprite;
|
||||
var floor: Phaser.GeomSprite;
|
||||
|
||||
function create() {
|
||||
|
||||
circle = myGame.add.geomSprite(200, 0);
|
||||
circle.createCircle(64);
|
||||
circle.acceleration.y = 100;
|
||||
circle.elasticity = 0.8;
|
||||
|
||||
// A simple floor
|
||||
floor = myGame.add.geomSprite(0, 550);
|
||||
floor.createRectangle(800, 50);
|
||||
floor.immovable = true;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
myGame.collide(circle, floor);
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,27 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update);
|
||||
var line;
|
||||
function create() {
|
||||
line = myGame.add.geomSprite(200, 200);
|
||||
line.createLine(400, 400);
|
||||
}
|
||||
function update() {
|
||||
//box.velocity.x = 0;
|
||||
//box.velocity.y = 0;
|
||||
//box.angularVelocity = 0;
|
||||
//box.angularAcceleration = 0;
|
||||
//if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
//{
|
||||
// box.angularVelocity = -200;
|
||||
//}
|
||||
//else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
//{
|
||||
// box.angularVelocity = 200;
|
||||
//}
|
||||
//if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
//{
|
||||
// box.velocity.copyFrom(myGame.motion.velocityFromAngle(box.angle, 200));
|
||||
//}
|
||||
}
|
||||
})();
|
|
@ -1,40 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update);
|
||||
|
||||
var line: Phaser.GeomSprite;
|
||||
|
||||
function create() {
|
||||
|
||||
line = myGame.add.geomSprite(200, 200);
|
||||
|
||||
line.createLine(400, 400);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
//box.velocity.x = 0;
|
||||
//box.velocity.y = 0;
|
||||
//box.angularVelocity = 0;
|
||||
//box.angularAcceleration = 0;
|
||||
|
||||
//if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
//{
|
||||
// box.angularVelocity = -200;
|
||||
//}
|
||||
//else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
//{
|
||||
// box.angularVelocity = 200;
|
||||
//}
|
||||
|
||||
//if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
//{
|
||||
// box.velocity.copyFrom(myGame.motion.velocityFromAngle(box.angle, 200));
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,31 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
|
||||
var p1;
|
||||
var p2;
|
||||
var p3;
|
||||
var p4;
|
||||
var d = 0;
|
||||
function create() {
|
||||
p1 = new Phaser.Point(myGame.stage.centerX, myGame.stage.centerY);
|
||||
p2 = new Phaser.Point(p1.x - 50, p1.y - 50);
|
||||
p3 = new Phaser.Point(p1.x - 100, p1.y - 100);
|
||||
p4 = new Phaser.Point(p1.x - 150, p1.y - 150);
|
||||
}
|
||||
function update() {
|
||||
p2.rotate(p1.x, p1.y, myGame.math.wrapAngle(d), true);
|
||||
p3.rotate(p1.x, p1.y, myGame.math.wrapAngle(d), true);
|
||||
p4.rotate(p1.x, p1.y, myGame.math.wrapAngle(d), true);
|
||||
d++;
|
||||
}
|
||||
function render() {
|
||||
myGame.stage.context.fillStyle = 'rgb(255,255,0)';
|
||||
myGame.stage.context.fillRect(p1.x, p1.y, 4, 4);
|
||||
myGame.stage.context.fillStyle = 'rgb(255,0,0)';
|
||||
myGame.stage.context.fillRect(p2.x, p2.y, 4, 4);
|
||||
myGame.stage.context.fillStyle = 'rgb(0,255,0)';
|
||||
myGame.stage.context.fillRect(p3.x, p3.y, 4, 4);
|
||||
myGame.stage.context.fillStyle = 'rgb(255,0,255)';
|
||||
myGame.stage.context.fillRect(p4.x, p4.y, 4, 4);
|
||||
}
|
||||
})();
|
|
@ -1,49 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
|
||||
|
||||
var p1:Phaser.Point;
|
||||
var p2:Phaser.Point;
|
||||
var p3:Phaser.Point;
|
||||
var p4:Phaser.Point;
|
||||
|
||||
var d: number = 0;
|
||||
|
||||
function create() {
|
||||
|
||||
p1 = new Phaser.Point(myGame.stage.centerX, myGame.stage.centerY);
|
||||
p2 = new Phaser.Point(p1.x - 50, p1.y - 50);
|
||||
p3 = new Phaser.Point(p1.x - 100, p1.y - 100);
|
||||
p4 = new Phaser.Point(p1.x - 150, p1.y - 150);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
p2.rotate(p1.x, p1.y, myGame.math.wrapAngle(d), true);
|
||||
p3.rotate(p1.x, p1.y, myGame.math.wrapAngle(d), true);
|
||||
p4.rotate(p1.x, p1.y, myGame.math.wrapAngle(d), true);
|
||||
|
||||
d++;
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
myGame.stage.context.fillStyle = 'rgb(255,255,0)';
|
||||
myGame.stage.context.fillRect(p1.x, p1.y, 4, 4);
|
||||
|
||||
myGame.stage.context.fillStyle = 'rgb(255,0,0)';
|
||||
myGame.stage.context.fillRect(p2.x, p2.y, 4, 4);
|
||||
|
||||
myGame.stage.context.fillStyle = 'rgb(0,255,0)';
|
||||
myGame.stage.context.fillRect(p3.x, p3.y, 4, 4);
|
||||
|
||||
myGame.stage.context.fillStyle = 'rgb(255,0,255)';
|
||||
myGame.stage.context.fillRect(p4.x, p4.y, 4, 4);
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,21 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update);
|
||||
var floor;
|
||||
function create() {
|
||||
for(var i = 0; i < 100; i++) {
|
||||
var p = myGame.add.geomSprite(myGame.stage.randomX, Math.random() * 100);
|
||||
p.createPoint();
|
||||
p.fillColor = 'rgb(255,255,255)';
|
||||
p.acceleration.y = 100 + Math.random() * 100;
|
||||
p.elasticity = 0.8;
|
||||
}
|
||||
// A simple floor
|
||||
floor = myGame.add.geomSprite(0, 550);
|
||||
floor.createRectangle(800, 50);
|
||||
floor.immovable = true;
|
||||
}
|
||||
function update() {
|
||||
myGame.collide(myGame.world.group, floor);
|
||||
}
|
||||
})();
|
|
@ -1,33 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update);
|
||||
|
||||
var floor: Phaser.GeomSprite;
|
||||
|
||||
function create() {
|
||||
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var p:Phaser.GeomSprite = myGame.add.geomSprite(myGame.stage.randomX, Math.random() * 100);
|
||||
p.createPoint();
|
||||
p.fillColor = 'rgb(255,255,255)';
|
||||
p.acceleration.y = 100 + Math.random() * 100;
|
||||
p.elasticity = 0.8;
|
||||
}
|
||||
|
||||
// A simple floor
|
||||
floor = myGame.add.geomSprite(0, 550);
|
||||
floor.createRectangle(800, 50);
|
||||
floor.immovable = true;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
myGame.collide(myGame.world.group, floor);
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,22 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update);
|
||||
var box1;
|
||||
var box2;
|
||||
function create() {
|
||||
box2 = myGame.add.geomSprite(300, 300).createRectangle(128, 128);
|
||||
box1 = myGame.add.geomSprite(320, 100).createRectangle(64, 64);
|
||||
box1.velocity.y = 50;
|
||||
}
|
||||
function update() {
|
||||
if(box1.collide(box2) == true) {
|
||||
box1.fillColor = 'rgb(255,0,0)';
|
||||
} else {
|
||||
box1.fillColor = 'rgb(0,255,0)';
|
||||
}
|
||||
}
|
||||
function checkPoints() {
|
||||
if(box2.rect.containsPoint(box1.rect.topLeft)) {
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,41 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update);
|
||||
|
||||
var box1: Phaser.GeomSprite;
|
||||
var box2: Phaser.GeomSprite;
|
||||
|
||||
function create() {
|
||||
|
||||
box2 = myGame.add.geomSprite(300, 300).createRectangle(128, 128);
|
||||
box1 = myGame.add.geomSprite(320, 100).createRectangle(64, 64);
|
||||
|
||||
box1.velocity.y = 50;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (box1.collide(box2) == true)
|
||||
{
|
||||
box1.fillColor = 'rgb(255,0,0)';
|
||||
}
|
||||
else
|
||||
{
|
||||
box1.fillColor = 'rgb(0,255,0)';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function checkPoints() {
|
||||
|
||||
if (box2.rect.containsPoint(box1.rect.topLeft))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,24 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update);
|
||||
var box;
|
||||
function create() {
|
||||
box = myGame.add.geomSprite(0, 0);
|
||||
box.createRectangle(64, 64);
|
||||
box.renderOutline = false;
|
||||
}
|
||||
function update() {
|
||||
box.velocity.x = 0;
|
||||
box.velocity.y = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
box.velocity.x = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
box.velocity.x = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
box.velocity.y = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
box.velocity.y = 200;
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -1,43 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update);
|
||||
|
||||
var box: Phaser.GeomSprite;
|
||||
|
||||
function create() {
|
||||
|
||||
box = myGame.add.geomSprite(0, 0);
|
||||
|
||||
box.createRectangle(64, 64);
|
||||
box.renderOutline = false;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
box.velocity.x = 0;
|
||||
box.velocity.y = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
box.velocity.x = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
box.velocity.x = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
box.velocity.y = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
box.velocity.y = 200;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,34 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('ball5', 'assets/sprites/purple_ball.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var segment;
|
||||
function create() {
|
||||
myGame.verlet.friction = 1;
|
||||
myGame.verlet.hideNearestEntityCircle = true;
|
||||
var points = [];
|
||||
var startX = 100;
|
||||
var startY = 200;
|
||||
var spacing = 20;
|
||||
for(var i = 0; i < 30; i++) {
|
||||
points.push(new Phaser.Vector2(startX + (i * spacing), startY));
|
||||
}
|
||||
segment = myGame.verlet.createLineSegments(points, 0.5);
|
||||
segment.loadGraphic('ball5');
|
||||
segment.hideConstraints = false;
|
||||
segment.pin(0);
|
||||
segment.pin(points.length - 1);
|
||||
}
|
||||
function update() {
|
||||
}
|
||||
function render() {
|
||||
myGame.verlet.render();
|
||||
//myGame.stage.context.fillStyle = 'rgb(255,255,0)';
|
||||
//myGame.stage.context.fillRect(p1.x, p1.y, 4, 4);
|
||||
//myGame.stage.context.fillStyle = 'rgb(255,0,0)';
|
||||
//myGame.stage.context.fillRect(p2.x, p2.y, 4, 4);
|
||||
}
|
||||
})();
|
|
@ -1,55 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.loader.addImageFile('ball5', 'assets/sprites/purple_ball.png');
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var segment: Phaser.Verlet.Composite;
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.verlet.friction = 1;
|
||||
myGame.verlet.hideNearestEntityCircle = true;
|
||||
|
||||
var points: Phaser.Vector2[] = [];
|
||||
var startX: number = 100;
|
||||
var startY: number = 200;
|
||||
var spacing: number = 20;
|
||||
|
||||
for (var i = 0; i < 30; i++)
|
||||
{
|
||||
points.push(new Phaser.Vector2(startX + (i * spacing), startY));
|
||||
}
|
||||
|
||||
segment = myGame.verlet.createLineSegments(points, 0.5);
|
||||
segment.loadGraphic('ball5');
|
||||
segment.hideConstraints = false;
|
||||
|
||||
segment.pin(0);
|
||||
segment.pin(points.length - 1);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
myGame.verlet.render();
|
||||
|
||||
//myGame.stage.context.fillStyle = 'rgb(255,255,0)';
|
||||
//myGame.stage.context.fillRect(p1.x, p1.y, 4, 4);
|
||||
|
||||
//myGame.stage.context.fillStyle = 'rgb(255,0,0)';
|
||||
//myGame.stage.context.fillRect(p2.x, p2.y, 4, 4);
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,21 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
|
||||
var p1;
|
||||
var p2;
|
||||
var d = 0;
|
||||
function create() {
|
||||
p1 = new Phaser.Point(200, 300);
|
||||
p2 = new Phaser.Point(300, 300);
|
||||
}
|
||||
function update() {
|
||||
p1.rotate(p2.x, p2.y, myGame.math.wrapAngle(d), true);
|
||||
d++;
|
||||
}
|
||||
function render() {
|
||||
myGame.stage.context.fillStyle = 'rgb(255,255,0)';
|
||||
myGame.stage.context.fillRect(p1.x, p1.y, 4, 4);
|
||||
myGame.stage.context.fillStyle = 'rgb(255,0,0)';
|
||||
myGame.stage.context.fillRect(p2.x, p2.y, 4, 4);
|
||||
}
|
||||
})();
|
|
@ -1,36 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
|
||||
|
||||
var p1:Phaser.Point;
|
||||
var p2:Phaser.Point;
|
||||
var d: number = 0;
|
||||
|
||||
function create() {
|
||||
|
||||
p1 = new Phaser.Point(200, 300);
|
||||
p2 = new Phaser.Point(300, 300);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
p1.rotate(p2.x, p2.y, myGame.math.wrapAngle(d), true);
|
||||
|
||||
d++;
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
myGame.stage.context.fillStyle = 'rgb(255,255,0)';
|
||||
myGame.stage.context.fillRect(p1.x, p1.y, 4, 4);
|
||||
|
||||
myGame.stage.context.fillStyle = 'rgb(255,0,0)';
|
||||
myGame.stage.context.fillRect(p2.x, p2.y, 4, 4);
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,43 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
|
||||
var p1;
|
||||
var p2;
|
||||
var p3;
|
||||
var p4;
|
||||
var d2 = 0;
|
||||
var d3 = 0;
|
||||
var d4 = 0;
|
||||
function create() {
|
||||
p1 = new Phaser.Point(myGame.stage.centerX, myGame.stage.centerY);
|
||||
p2 = new Phaser.Point(p1.x - 50, p1.y - 50);
|
||||
p3 = new Phaser.Point(p2.x - 50, p2.y - 50);
|
||||
p4 = new Phaser.Point(p3.x - 50, p3.y - 50);
|
||||
}
|
||||
function update() {
|
||||
p2.rotate(p1.x, p1.y, myGame.math.wrapAngle(d2), true, 150);
|
||||
p3.rotate(p2.x, p2.y, myGame.math.wrapAngle(d3), true, 50);
|
||||
p4.rotate(p3.x, p3.y, myGame.math.wrapAngle(d4), true, 100);
|
||||
d2 += 1;
|
||||
d3 += 4;
|
||||
d4 += 6;
|
||||
}
|
||||
function render() {
|
||||
myGame.stage.context.strokeStyle = 'rgb(0,255,255)';
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.moveTo(p1.x, p1.y);
|
||||
myGame.stage.context.lineTo(p2.x, p2.y);
|
||||
myGame.stage.context.lineTo(p3.x, p3.y);
|
||||
myGame.stage.context.lineTo(p4.x, p4.y);
|
||||
myGame.stage.context.stroke();
|
||||
myGame.stage.context.closePath();
|
||||
myGame.stage.context.fillStyle = 'rgb(255,255,0)';
|
||||
myGame.stage.context.fillRect(p1.x, p1.y, 4, 4);
|
||||
myGame.stage.context.fillStyle = 'rgb(255,0,0)';
|
||||
myGame.stage.context.fillRect(p2.x, p2.y, 4, 4);
|
||||
myGame.stage.context.fillStyle = 'rgb(0,255,0)';
|
||||
myGame.stage.context.fillRect(p3.x, p3.y, 4, 4);
|
||||
myGame.stage.context.fillStyle = 'rgb(255,0,255)';
|
||||
myGame.stage.context.fillRect(p4.x, p4.y, 4, 4);
|
||||
}
|
||||
})();
|
|
@ -1,62 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
|
||||
|
||||
var p1:Phaser.Point;
|
||||
var p2:Phaser.Point;
|
||||
var p3:Phaser.Point;
|
||||
var p4:Phaser.Point;
|
||||
|
||||
var d2: number = 0;
|
||||
var d3: number = 0;
|
||||
var d4: number = 0;
|
||||
|
||||
function create() {
|
||||
|
||||
p1 = new Phaser.Point(myGame.stage.centerX, myGame.stage.centerY);
|
||||
p2 = new Phaser.Point(p1.x - 50, p1.y - 50);
|
||||
p3 = new Phaser.Point(p2.x - 50, p2.y - 50);
|
||||
p4 = new Phaser.Point(p3.x - 50, p3.y - 50);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
p2.rotate(p1.x, p1.y, myGame.math.wrapAngle(d2), true, 150);
|
||||
p3.rotate(p2.x, p2.y, myGame.math.wrapAngle(d3), true, 50);
|
||||
p4.rotate(p3.x, p3.y, myGame.math.wrapAngle(d4), true, 100);
|
||||
|
||||
d2 += 1;
|
||||
d3 += 4;
|
||||
d4 += 6;
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
myGame.stage.context.strokeStyle = 'rgb(0,255,255)';
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.moveTo(p1.x, p1.y);
|
||||
myGame.stage.context.lineTo(p2.x, p2.y);
|
||||
myGame.stage.context.lineTo(p3.x, p3.y);
|
||||
myGame.stage.context.lineTo(p4.x, p4.y);
|
||||
myGame.stage.context.stroke();
|
||||
myGame.stage.context.closePath();
|
||||
|
||||
myGame.stage.context.fillStyle = 'rgb(255,255,0)';
|
||||
myGame.stage.context.fillRect(p1.x, p1.y, 4, 4);
|
||||
|
||||
myGame.stage.context.fillStyle = 'rgb(255,0,0)';
|
||||
myGame.stage.context.fillRect(p2.x, p2.y, 4, 4);
|
||||
|
||||
myGame.stage.context.fillStyle = 'rgb(0,255,0)';
|
||||
myGame.stage.context.fillRect(p3.x, p3.y, 4, 4);
|
||||
|
||||
myGame.stage.context.fillStyle = 'rgb(255,0,255)';
|
||||
myGame.stage.context.fillRect(p4.x, p4.y, 4, 4);
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,71 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
|
||||
var origin;
|
||||
var p1;
|
||||
var p2;
|
||||
var p3;
|
||||
var p4;
|
||||
var d = 0;
|
||||
function create() {
|
||||
// This creates a box made up of 4 edge-points and rotates it around the origin
|
||||
origin = new Phaser.Point(400, 300);
|
||||
p1 = new Phaser.Point()// top left
|
||||
;
|
||||
p2 = new Phaser.Point()// top right
|
||||
;
|
||||
p3 = new Phaser.Point()// bottom right
|
||||
;
|
||||
p4 = new Phaser.Point()// bottom left
|
||||
;
|
||||
}
|
||||
function update() {
|
||||
// top left (red)
|
||||
p1.rotate(origin.x, origin.y, myGame.math.wrapAngle(d), true, 200);
|
||||
// top right (yellow)
|
||||
p2.rotate(origin.x, origin.y, myGame.math.wrapAngle(d + 90), true, 200);
|
||||
// bottom right (aqua)
|
||||
p3.rotate(origin.x, origin.y, myGame.math.wrapAngle(d + 180), true, 200);
|
||||
// bottom left (blue)
|
||||
p4.rotate(origin.x, origin.y, myGame.math.wrapAngle(d + 270), true, 200);
|
||||
d++;
|
||||
}
|
||||
function render() {
|
||||
// Render the shape
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.fillStyle = 'rgba(0,255,0,0.2)';
|
||||
myGame.stage.context.strokeStyle = 'rgb(0,255,0)';
|
||||
myGame.stage.context.lineWidth = 1;
|
||||
myGame.stage.context.moveTo(p1.x, p1.y);
|
||||
myGame.stage.context.lineTo(p2.x, p2.y);
|
||||
myGame.stage.context.lineTo(p3.x, p3.y);
|
||||
myGame.stage.context.lineTo(p4.x, p4.y);
|
||||
myGame.stage.context.lineTo(p1.x, p1.y);
|
||||
myGame.stage.context.fill();
|
||||
myGame.stage.context.stroke();
|
||||
myGame.stage.context.closePath();
|
||||
// Render the points
|
||||
myGame.stage.context.fillStyle = 'rgb(255,255,255)';
|
||||
myGame.stage.context.fillRect(origin.x, origin.y, 4, 4);
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.fillStyle = 'rgb(255,0,0)';
|
||||
myGame.stage.context.arc(p1.x, p1.y, 4, 0, Math.PI * 2);
|
||||
myGame.stage.context.fill();
|
||||
myGame.stage.context.closePath();
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.fillStyle = 'rgb(255,255,0)';
|
||||
myGame.stage.context.arc(p2.x, p2.y, 4, 0, Math.PI * 2);
|
||||
myGame.stage.context.fill();
|
||||
myGame.stage.context.closePath();
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.fillStyle = 'rgb(0,255,255)';
|
||||
myGame.stage.context.arc(p3.x, p3.y, 4, 0, Math.PI * 2);
|
||||
myGame.stage.context.fill();
|
||||
myGame.stage.context.closePath();
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.fillStyle = 'rgb(0,0,255)';
|
||||
myGame.stage.context.arc(p4.x, p4.y, 4, 0, Math.PI * 2);
|
||||
myGame.stage.context.fill();
|
||||
myGame.stage.context.closePath();
|
||||
}
|
||||
})();
|
|
@ -1,95 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
|
||||
|
||||
var origin:Phaser.Point;
|
||||
|
||||
var p1:Phaser.Point;
|
||||
var p2:Phaser.Point;
|
||||
var p3:Phaser.Point;
|
||||
var p4:Phaser.Point;
|
||||
|
||||
var d: number = 0;
|
||||
|
||||
function create() {
|
||||
|
||||
// This creates a box made up of 4 edge-points and rotates it around the origin
|
||||
|
||||
origin = new Phaser.Point(400, 300);
|
||||
|
||||
p1 = new Phaser.Point(); // top left
|
||||
p2 = new Phaser.Point(); // top right
|
||||
p3 = new Phaser.Point(); // bottom right
|
||||
p4 = new Phaser.Point(); // bottom left
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
// top left (red)
|
||||
p1.rotate(origin.x, origin.y, myGame.math.wrapAngle(d), true, 200);
|
||||
|
||||
// top right (yellow)
|
||||
p2.rotate(origin.x, origin.y, myGame.math.wrapAngle(d + 90), true, 200);
|
||||
|
||||
// bottom right (aqua)
|
||||
p3.rotate(origin.x, origin.y, myGame.math.wrapAngle(d + 180), true, 200);
|
||||
|
||||
// bottom left (blue)
|
||||
p4.rotate(origin.x, origin.y, myGame.math.wrapAngle(d + 270), true, 200);
|
||||
|
||||
d++;
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
// Render the shape
|
||||
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.fillStyle = 'rgba(0,255,0,0.2)';
|
||||
myGame.stage.context.strokeStyle = 'rgb(0,255,0)';
|
||||
myGame.stage.context.lineWidth = 1;
|
||||
myGame.stage.context.moveTo(p1.x, p1.y);
|
||||
myGame.stage.context.lineTo(p2.x, p2.y);
|
||||
myGame.stage.context.lineTo(p3.x, p3.y);
|
||||
myGame.stage.context.lineTo(p4.x, p4.y);
|
||||
myGame.stage.context.lineTo(p1.x, p1.y);
|
||||
myGame.stage.context.fill();
|
||||
myGame.stage.context.stroke();
|
||||
myGame.stage.context.closePath();
|
||||
|
||||
// Render the points
|
||||
|
||||
myGame.stage.context.fillStyle = 'rgb(255,255,255)';
|
||||
myGame.stage.context.fillRect(origin.x, origin.y, 4, 4);
|
||||
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.fillStyle = 'rgb(255,0,0)';
|
||||
myGame.stage.context.arc(p1.x, p1.y, 4, 0, Math.PI * 2);
|
||||
myGame.stage.context.fill();
|
||||
myGame.stage.context.closePath();
|
||||
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.fillStyle = 'rgb(255,255,0)';
|
||||
myGame.stage.context.arc(p2.x, p2.y, 4, 0, Math.PI * 2);
|
||||
myGame.stage.context.fill();
|
||||
myGame.stage.context.closePath();
|
||||
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.fillStyle = 'rgb(0,255,255)';
|
||||
myGame.stage.context.arc(p3.x, p3.y, 4, 0, Math.PI * 2);
|
||||
myGame.stage.context.fill();
|
||||
myGame.stage.context.closePath();
|
||||
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.fillStyle = 'rgb(0,0,255)';
|
||||
myGame.stage.context.arc(p4.x, p4.y, 4, 0, Math.PI * 2);
|
||||
myGame.stage.context.fill();
|
||||
myGame.stage.context.closePath();
|
||||
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,54 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
|
||||
var origin;
|
||||
var origin2;
|
||||
var points = [];
|
||||
var points2 = [];
|
||||
var d = 0;
|
||||
var d2 = 0;
|
||||
var m = 64;
|
||||
function create() {
|
||||
// Let's have some fun :)
|
||||
origin = new Phaser.Point(300, 200);
|
||||
origin2 = new Phaser.Point(600, 350);
|
||||
for(var i = 0; i < m; i++) {
|
||||
points.push(new Phaser.Point());
|
||||
points2.push(new Phaser.Point());
|
||||
}
|
||||
}
|
||||
function update() {
|
||||
for(var i = 0; i < m; i++) {
|
||||
points[i].rotate(origin.x, origin.y, myGame.math.wrapAngle(d + (i * (360 / m))), true, i * 5);
|
||||
//points2[i].rotate(origin2.x, origin2.y, myGame.math.wrapAngle(d2 + (i * (360/m))), true, i * 10);
|
||||
//points[i].rotate(origin.x, origin.y, myGame.math.wrapAngle(d + (i * (360/m))), true, 200);
|
||||
points2[i].rotate(origin2.x, origin2.y, myGame.math.wrapAngle(d2 + (i * (360 / m))), true, 200);
|
||||
}
|
||||
d -= 2;
|
||||
d2 += 2;
|
||||
}
|
||||
function render() {
|
||||
// Render the shape
|
||||
myGame.stage.context.save();
|
||||
//myGame.stage.context.globalCompositeOperation = 'xor';
|
||||
myGame.stage.context.globalCompositeOperation = 'lighter';
|
||||
myGame.stage.context.lineWidth = 20;
|
||||
for(var i = 0; i < m; i++) {
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.strokeStyle = 'rgba(255,' + Math.round(i * (255 / m)).toString() + ',0,1)';
|
||||
myGame.stage.context.moveTo(origin.x, origin.y);
|
||||
myGame.stage.context.lineTo(points[i].x, points[i].y);
|
||||
myGame.stage.context.stroke();
|
||||
myGame.stage.context.closePath();
|
||||
}
|
||||
for(var i = 0; i < m; i++) {
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.strokeStyle = 'rgba(0,' + Math.round(i * (255 / m)).toString() + ',255,1)';
|
||||
myGame.stage.context.moveTo(origin2.x, origin2.y);
|
||||
myGame.stage.context.lineTo(points2[i].x, points2[i].y);
|
||||
myGame.stage.context.stroke();
|
||||
myGame.stage.context.closePath();
|
||||
}
|
||||
myGame.stage.context.restore();
|
||||
}
|
||||
})();
|
|
@ -1,82 +0,0 @@
|
|||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
|
||||
|
||||
var origin:Phaser.Point;
|
||||
var origin2:Phaser.Point;
|
||||
|
||||
var points:Phaser.Point[] = [];
|
||||
var points2:Phaser.Point[] = [];
|
||||
|
||||
var d: number = 0;
|
||||
var d2: number = 0;
|
||||
var m: number = 64;
|
||||
|
||||
function create() {
|
||||
|
||||
// Let's have some fun :)
|
||||
|
||||
origin = new Phaser.Point(300, 200);
|
||||
origin2 = new Phaser.Point(600, 350);
|
||||
|
||||
for (var i = 0; i < m; i++)
|
||||
{
|
||||
points.push(new Phaser.Point());
|
||||
points2.push(new Phaser.Point());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
for (var i = 0; i < m; i++)
|
||||
{
|
||||
points[i].rotate(origin.x, origin.y, myGame.math.wrapAngle(d + (i * (360/m))), true, i * 5);
|
||||
//points2[i].rotate(origin2.x, origin2.y, myGame.math.wrapAngle(d2 + (i * (360/m))), true, i * 10);
|
||||
|
||||
//points[i].rotate(origin.x, origin.y, myGame.math.wrapAngle(d + (i * (360/m))), true, 200);
|
||||
points2[i].rotate(origin2.x, origin2.y, myGame.math.wrapAngle(d2 + (i * (360/m))), true, 200);
|
||||
}
|
||||
|
||||
d -= 2;
|
||||
d2 += 2;
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
// Render the shape
|
||||
|
||||
myGame.stage.context.save();
|
||||
//myGame.stage.context.globalCompositeOperation = 'xor';
|
||||
myGame.stage.context.globalCompositeOperation = 'lighter';
|
||||
myGame.stage.context.lineWidth = 20;
|
||||
|
||||
for (var i = 0; i < m; i++)
|
||||
{
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.strokeStyle = 'rgba(255,' + Math.round(i * (255/m)).toString() + ',0,1)';
|
||||
myGame.stage.context.moveTo(origin.x, origin.y);
|
||||
myGame.stage.context.lineTo(points[i].x, points[i].y);
|
||||
myGame.stage.context.stroke();
|
||||
myGame.stage.context.closePath();
|
||||
}
|
||||
|
||||
|
||||
for (var i = 0; i < m; i++)
|
||||
{
|
||||
myGame.stage.context.beginPath();
|
||||
myGame.stage.context.strokeStyle = 'rgba(0,' + Math.round(i * (255/m)).toString() + ',255,1)';
|
||||
myGame.stage.context.moveTo(origin2.x, origin2.y);
|
||||
myGame.stage.context.lineTo(points2[i].x, points2[i].y);
|
||||
myGame.stage.context.stroke();
|
||||
myGame.stage.context.closePath();
|
||||
}
|
||||
|
||||
myGame.stage.context.restore();
|
||||
|
||||
}
|
||||
|
||||
})();
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue