Skip to content

Commit

Permalink
Some maintenance here and there including removing the Fabrique.Plugi…
Browse files Browse the repository at this point in the history
…ns namespace
  • Loading branch information
AleBles committed Dec 19, 2016
1 parent 9729c3c commit 8dcdba9
Show file tree
Hide file tree
Showing 14 changed files with 249 additions and 443 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.idea
.idea
.tscache
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Gruntfile.js
vendor
ts
.idea
buddy-spine
buddy-spine
.tscache
62 changes: 40 additions & 22 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = function (grunt) {
//Get some details from the package.json
pkg: grunt.file.readJSON('package.json'),
banner: '/*!\n' +
' * <%= pkg.name %> - version <%= pkg.version %> \n' +
' * <%= pkg.config.name %> - version <%= pkg.version %> \n' +
' * <%= pkg.description %>\n' +
' *\n' +
' * <%= pkg.author %>\n' +
Expand All @@ -24,31 +24,31 @@ module.exports = function (grunt) {
}
},
//Typescript settings per build
typescript: {
ts: {
options: {
module: 'amd',
target: 'es5',
sourceMap: true,
declaration: true,
references: [
'node_modules/phaser/typescript/pixi.d.ts',
'node_modules/phaser/typescript/phaser.d.ts'
],
noImplicitAny: true
},
dist: {
src: ['ts/**/*.ts'],
dest: 'build/<%= pkg.name %>.js'
dest: 'build/<%= pkg.config.name %>.js'
}
},
concat: {
definitions: {
src: ['vendor/Spine.d.ts', 'build/phaser-spine.d.ts'],
dest: 'build/phaser-spine.d.ts'
},
dist: {
src: ['vendor/Spine.js', 'build/phaser-spine.js'],
dest: 'build/phaser-spine.js'
watch: {
files: ['ts/**/*.ts'],
tasks: ['ts'],
options: {
livereload: true
}
},
connect: {
server: {
options: {
port: 8080
}
}
},
uglify: {
Expand All @@ -68,13 +68,23 @@ module.exports = function (grunt) {
},
dist: {
files: {
'build/<%= pkg.name %>.min.js': [
'build/<%= pkg.config.name %>.min.js': [
'vendor/Spine.js',
'build/<%= pkg.name %>.js'
'build/<%= pkg.config.name %>.js'
]
}
}
},
concat: {
definitions: {
src: ['vendor/Spine.d.ts', 'build/phaser-spine.d.ts'],
dest: 'build/phaser-spine.d.ts'
},
dist: {
src: ['vendor/Spine.js', 'build/phaser-spine.js'],
dest: 'build/phaser-spine.js'
}
},
clean: {
dist: ['build']
}
Expand All @@ -84,15 +94,23 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-banner');
grunt.loadNpmTasks('grunt-typescript');
grunt.loadNpmTasks('grunt-ts');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');

//dist Build
grunt.registerTask('dist', [
'clean:dist',
'typescript:dist',
'uglify:dist',
'clean:dist', //Clean the dist folder
'ts:dist',//Run typescript on the preprocessed files, for dist (client)
'uglify:dist', //Minify everything
'concat',
'usebanner:dist'
'usebanner:dist' //Minify everything
]);

grunt.registerTask('dev', [
'ts:dist',
'connect',
'watch'
]);

};
191 changes: 41 additions & 150 deletions build/phaser-spine.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -753,52 +753,46 @@ declare module spine {
public getHeight(): number;
}
}
declare module Fabrique {
module Plugins {
interface SpineObjectFactory extends Phaser.GameObjectFactory {
spine: (x: number, y: number, key: string, scalingVariant?: string, group?: Phaser.Group) => Fabrique.Spine;
}
interface SpineObjectCreator extends Phaser.GameObjectCreator {
spine: (x: number, y: number, key: string, scalingVariant?: string, group?: Phaser.Group) => Fabrique.Spine;
}
interface SpineCache extends Phaser.Cache {
addSpine: (key: string, data: any) => void;
getSpine: (key: string) => any;
spine: {
[key: string]: SpineCacheData;
};
}
interface SpineLoader extends Phaser.Loader {
spine: (key: string, url: string, scalingVariants?: string[]) => void;
cache: SpineCache;
}
interface SpineGame extends Phaser.Game {
add: SpineObjectFactory;
load: SpineLoader;
cache: SpineCache;
}
interface SpineCacheData {
atlas: string;
basePath: string;
variants: string[];
}
class Spine extends Phaser.Plugin {
static RESOLUTION_REGEXP: RegExp;
constructor(game: SpineGame, parent: Phaser.PluginManager);
private addSpineLoader();
/**
* Extends the GameObjectFactory prototype with the support of adding spine. this allows us to add spine methods to the game just like any other object:
* game.add.spine();
*/
private addSpineFactory();
/**
* Extends the Phaser.Cache prototype with spine properties
*/
private addSpineCache();
}
declare module PhaserSpine {
interface SpineObjectFactory extends Phaser.GameObjectFactory {
spine: (x: number, y: number, key: string, scalingVariant?: string, group?: Phaser.Group) => PhaserSpine.Spine;
}
interface SpineObjectCreator extends Phaser.GameObjectCreator {
spine: (x: number, y: number, key: string, scalingVariant?: string, group?: Phaser.Group) => PhaserSpine.Spine;
}
interface SpineCache extends Phaser.Cache {
addSpine: (key: string, data: any) => void;
getSpine: (key: string) => any;
spine: {
[key: string]: SpineCacheData;
};
}
interface SpineLoader extends Phaser.Loader {
spine: (key: string, url: string, scalingVariants?: string[]) => void;
cache: SpineCache;
}
interface SpineGame extends Phaser.Game {
add: SpineObjectFactory;
load: SpineLoader;
cache: SpineCache;
}
interface SpineCacheData {
atlas: string;
basePath: string;
variants: string[];
}
class SpinePlugin extends Phaser.Plugin {
static RESOLUTION_REGEXP: RegExp;
constructor(game: SpineGame, parent: Phaser.PluginManager);
private addSpineLoader();
private addSpineFactory();
private addSpineCache();
}
}
declare module "phaser-spine" {
export = PhaserSpine;
}
declare module Fabrique {
declare module PhaserSpine {
class Spine extends Phaser.Group {
private skeleton;
private skeletonData;
Expand All @@ -807,132 +801,29 @@ declare module Fabrique {
private slotContainers;
private lastTime;
private imageScale;
game: Fabrique.Plugins.SpineGame;
/**
* @class Spine
* @extends Phaser.Group
* @constructor
* @param game {Phaser.Game} the game reference to add this object
* @param key {String} the key to find the assets for this object
*/
constructor(game: Fabrique.Plugins.SpineGame, key: string, scalingVariant?: string);
game: PhaserSpine.SpineGame;
constructor(game: PhaserSpine.SpineGame, key: string, scalingVariant?: string);
autoUpdate: boolean;
private getScaleFromVariant(variant);
/**
* Update the spine skeleton and its animations by delta time (dt)
*
* @method update
* @param dt {Number} Delta time. Time by which the animation should be updated
*/
update(dt?: number): void;
/**
* Children should always be destroyed
*
* @param destroyChildren
* @param soft
*/
destroy(destroyChildren?: boolean, soft?: boolean): void;
/**
* When autoupdate is set to yes this function is used as pixi's updateTransform function
*
* @method autoUpdateTransform
* @private
*/
autoUpdateTransform(): void;
/**
* Create a new sprite to be used with spine.RegionAttachment
*
* @method createSprite
* @param slot {spine.Slot} The slot to which the attachment is parented
* @param attachment {spine.RegionAttachment} The attachment that the sprite will represent
* @private
*/
createSprite(slot: any, attachment: any): Phaser.Sprite;
createMesh(slot: any, attachment: any): Phaser.Rope;
/**
* [setMixByName wrap to stateData.setMixByName]
* @param {String} fromName [source animation name]
* @param {String} toName [target animation name]
* @param {Float} duration [Duration in the transition of the animations]
*/
setMixByName(fromName: string, toName: string, duration: number): void;
/**
* exposing the state's setAnimation
* We override the original runtime's error because warnings dont stop the VM
*
* @param {number} trackIndex
* @param {string} animationName
* @param {boolean} loop
* @param {number} delay
* @returns {any}
*/
setAnimationByName(trackIndex: number, animationName: string, loop?: boolean): spine.TrackEntry;
/**
* exposing the state's addAnimation
* We override the original runtime's error because warnings dont stop the VM
*
* @param {number} trackIndex
* @param {string} animationName
* @param {boolean} loop
* @param {number} delay
* @returns {any}
*/
addAnimationByName(trackIndex: number, animationName: string, loop?: boolean, delay?: number): spine.TrackEntry;
/**
* Exposing the skeleton's method to change the skin by skinName
* We override the original runtime's error because warnings dont stop the VM
*
* @param {string} skinName The name of the skin we'd like to set
*/
setSkinByName(skinName: string): void;
/**
* Exposing the skeleton's method to change the skin
*
* @param skin
*/
setSkin(skin: spine.Skin): void;
/**
* Set to initial setup pose
*/
setToSetupPose(): void;
/**
* You can combine skins here by supplying a name for the new skin, and then a nummer of existing skins names that needed to be combined in the new skin
* If the skins that will be combined contain any double attachment, only the first attachment will be added to the newskin.
* any subsequent attachment that is double will not be added!
*
* @param newSkinName
* @param skinNames
*/
createCombinedSkin(newSkinName: string, ...skinNames: string[]): spine.Skin;
}
}
declare module Fabrique {
/**
* Supporting class to load images from spine atlases as per spine spec.
*
* @class SpineTextureLoader
* @uses EventTarget
* @constructor
* @param basePath {String} Tha base path where to look for the images to be loaded
* @param crossorigin {Boolean} Whether requests should be treated as crossorigin
*/
declare module PhaserSpine {
class SpineTextureLoader {
private game;
constructor(game: Phaser.Game);
/**
* Starts loading a base texture as per spine specification
*
* @method load
* @param page {spine.AtlasPage} Atlas page to which texture belongs
* @param file {String} The file to load, this is just the file path relative to the base path configured in the constructor
*/
load: (page: any, file: string, atlas: spine.Atlas) => void;
/**
* Unloads a previously loaded texture as per spine specification
*
* @method unload
* @param texture {BaseTexture} Texture object to destroy
*/
unload: (texture: PIXI.BaseTexture) => void;
}
}
Loading

0 comments on commit 8dcdba9

Please sign in to comment.