From dfee9f9b2fd1193c0dae5fd7118832d08d697085 Mon Sep 17 00:00:00 2001 From: Florent Cailhol Date: Wed, 23 Oct 2013 14:15:56 +0200 Subject: [PATCH] Add new Grunt build --- .gitignore | 8 +- Gruntfile.js | 168 +++++++ examples/_site/examples.json | 819 ++++++++++++++++++++++++++-------- examples/_site/view_full.html | 4 +- examples/_site/view_lite.html | 4 +- package.json | 22 +- src/Intro.js | 2 +- src/Phaser.js | 8 +- src/core/Game.js | 25 +- tasks/examples.js | 49 ++ tasks/umd.js | 35 ++ 11 files changed, 920 insertions(+), 224 deletions(-) create mode 100644 Gruntfile.js create mode 100644 tasks/examples.js create mode 100644 tasks/umd.js diff --git a/.gitignore b/.gitignore index 53a214901..e3173cf06 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,13 @@ +# System and IDE files .DS_Store .idea Phaser OSX.sublime-project Phaser OSX.sublime-workspace Phaser.sublime-project Phaser.sublime-workspace -node_modules + +# Vendors +node_modules/ + +# Build +dist/ diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 000000000..0e12c14be --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,168 @@ +module.exports = function (grunt) { + + grunt.loadNpmTasks('grunt-contrib-clean'); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-connect'); + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadTasks('./tasks'); + + grunt.initConfig({ + compile_dir: 'dist', + src: { + phaser: [ + 'src/Intro.js', + 'src/pixi/Pixi.js', + 'src/Phaser.js', + 'src/utils/Utils.js', + 'src/pixi/core/Matrix.js', + 'src/pixi/core/Point.js', + 'src/pixi/core/Rectangle.js', + 'src/pixi/display/DisplayObject.js', + 'src/pixi/display/DisplayObjectContainer.js', + 'src/pixi/display/Sprite.js', + 'src/pixi/display/Stage.js', + 'src/pixi/extras/CustomRenderable.js', + 'src/pixi/extras/Strip.js', + 'src/pixi/extras/Rope.js', + 'src/pixi/extras/TilingSprite.js', + 'src/pixi/filters/FilterBlock.js', + 'src/pixi/filters/MaskFilter.js', + 'src/pixi/primitives/Graphics.js', + 'src/pixi/renderers/canvas/CanvasGraphics.js', + 'src/pixi/renderers/canvas/CanvasRenderer.js', + 'src/pixi/renderers/webgl/WebGLBatch.js', + 'src/pixi/renderers/webgl/WebGLGraphics.js', + 'src/pixi/renderers/webgl/WebGLRenderer.js', + 'src/pixi/renderers/webgl/WebGLRenderGroup.js', + 'src/pixi/renderers/webgl/WebGLShaders.js', + 'src/pixi/text/BitmapText.js', + 'src/pixi/text/Text.js', + 'src/pixi/textures/BaseTexture.js', + 'src/pixi/textures/Texture.js', + 'src/pixi/textures/RenderTexture.js', + 'src/pixi/utils/EventTarget.js', + 'src/pixi/utils/Polyk.js', + 'src/core/Camera.js', + 'src/core/State.js', + 'src/core/StateManager.js', + 'src/core/LinkedList.js', + 'src/core/Signal.js', + 'src/core/SignalBinding.js', + 'src/core/Plugin.js', + 'src/core/PluginManager.js', + 'src/core/Stage.js', + 'src/core/Group.js', + 'src/core/World.js', + 'src/core/Game.js', + 'src/input/Input.js', + 'src/input/Key.js', + 'src/input/Keyboard.js', + 'src/input/Mouse.js', + 'src/input/MSPointer.js', + 'src/input/Pointer.js', + 'src/input/Touch.js', + 'src/input/InputHandler.js', + 'src/gameobjects/Events.js', + 'src/gameobjects/GameObjectFactory.js', + 'src/gameobjects/Sprite.js', + 'src/gameobjects/TileSprite.js', + 'src/gameobjects/Text.js', + 'src/gameobjects/BitmapText.js', + 'src/gameobjects/Button.js', + 'src/gameobjects/Graphics.js', + 'src/gameobjects/RenderTexture.js', + 'src/system/Canvas.js', + 'src/system/StageScaleMode.js', + 'src/system/Device.js', + 'src/system/RequestAnimationFrame.js', + 'src/math/RandomDataGenerator.js', + 'src/math/Math.js', + 'src/math/QuadTree.js', + 'src/geom/Circle.js', + 'src/geom/Point.js', + 'src/geom/Rectangle.js', + 'src/net/Net.js', + 'src/tween/TweenManager.js', + 'src/tween/Tween.js', + 'src/tween/Easing.js', + 'src/time/Time.js', + 'src/animation/AnimationManager.js', + 'src/animation/Animation.js', + 'src/animation/Frame.js', + 'src/animation/FrameData.js', + 'src/animation/AnimationParser.js', + 'src/loader/Cache.js', + 'src/loader/Loader.js', + 'src/loader/LoaderParser.js', + 'src/sound/Sound.js', + 'src/sound/SoundManager.js', + 'src/utils/Debug.js', + 'src/utils/Color.js', + 'src/physics/arcade/ArcadePhysics.js', + 'src/physics/arcade/Body.js', + 'src/particles/Particles.js', + 'src/particles/arcade/ArcadeParticles.js', + 'src/particles/arcade/Emitter.js', + 'src/tilemap/Tile.js', + 'src/tilemap/Tilemap.js', + 'src/tilemap/TilemapLayer.js', + 'src/tilemap/TilemapParser.js', + 'src/tilemap/Tileset.js', + 'src/PixiPatch.js' + ] + }, + pkg: grunt.file.readJSON('package.json'), + clean: ['<%= compile_dir %>'], + concat: { + phaser: { + options: { + process: { + data: { + version: '<%= pkg.version %>', + buildDate: '<%= grunt.template.today() %>' + } + } + }, + src: ['<%= src.phaser %>'], + dest: '<%= compile_dir %>/phaser.js' + } + }, + umd: { + phaser: { + src: '<%= concat.phaser.dest %>', + dest: '<%= umd.phaser.src %>' + } + }, + uglify: { + phaser: { + options: { + banner: '/*! Phaser v<%= pkg.version %> | (c) 2013 Photon Storm Ltd. */\n' + }, + src: ['<%= umd.phaser.dest %>'], + dest: '<%= compile_dir %>/phaser.min.js' + } + }, + examples: { + all: { + options: { + base: 'examples', + excludes: ['_site', 'assets', 'states', 'wip'] + }, + src: ['examples/**/*.js'], + dest: 'examples/_site/examples.json' + } + }, + connect: { + root: { + options: { + keepalive: true + } + } + } + }); + + grunt.registerTask('default', ['build', 'examples']); + grunt.registerTask('build', ['clean', 'concat', 'umd', 'uglify']); + +}; diff --git a/examples/_site/examples.json b/examples/_site/examples.json index b9ad235ad..40ed7616f 100644 --- a/examples/_site/examples.json +++ b/examples/_site/examples.json @@ -1,191 +1,632 @@ { -"basics": [ - { "file": "01+-+load+an+image.js", "title": "01 - load an image" } -], -"games": [ - { "file": "breakout.js", "title": "breakout" }, - { "file": "invaders.js", "title": "invaders" }, - { "file": "starstruck.js", "title": "starstruck" }, - { "file": "tanks.js", "title": "tanks" } -], -"animation": [ - { "file": "change+texture+on+click.js", "title": "change texture on click" }, - { "file": "local+json+object.js", "title": "local json object" }, - { "file": "looped+animation.js", "title": "looped animation" }, - { "file": "multiple+anims.js", "title": "multiple anims" }, - { "file": "sprite+sheet.js", "title": "sprite sheet" }, - { "file": "texture+packer+json+hash.js", "title": "texture packer json hash" } -], -"audio": [ - { "file": "loop.js", "title": "loop" }, - { "file": "play+music.js", "title": "play music" } -], -"buttons": [ - { "file": "action+on+click.js", "title": "action on click" }, - { "file": "changing+the+frames.js", "title": "changing the frames" }, - { "file": "rotated+buttons.js", "title": "rotated buttons" } -], -"camera": [ - { "file": "basic+follow.js", "title": "basic follow" }, - { "file": "camera+cull.js", "title": "camera cull" }, - { "file": "follow+styles.js", "title": "follow styles" }, - { "file": "moving+the+camera.js", "title": "moving the camera" }, - { "file": "world+sprite.js", "title": "world sprite" } -], -"collision": [ - { "file": "bounding+box.js", "title": "bounding box" }, - { "file": "group+vs+group.js", "title": "group vs group" }, - { "file": "larger+bounding+box.js", "title": "larger bounding box" }, - { "file": "offset+bounding+box.js", "title": "offset bounding box" }, - { "file": "sprite+tiles.js", "title": "sprite tiles" }, - { "file": "sprite+vs+group.js", "title": "sprite vs group" }, - { "file": "sprite+vs+sprite+custom.js", "title": "sprite vs sprite custom" }, - { "file": "sprite+vs+sprite.js", "title": "sprite vs sprite" }, - { "file": "transform.js", "title": "transform" }, - { "file": "vertical+collision.js", "title": "vertical collision" } -], -"display": [ - { "file": "fullscreen.js", "title": "fullscreen" }, - { "file": "graphics.js", "title": "graphics" }, - { "file": "render+crisp.js", "title": "render crisp" } -], -"geometry": [ - { "file": "circle.js", "title": "circle" }, - { "file": "line.js", "title": "line" }, - { "file": "playing+with+points.js", "title": "playing with points" }, - { "file": "rectangle.js", "title": "rectangle" }, - { "file": "rotate+point.js", "title": "rotate point" } -], -"groups": [ - { "file": "add+a+sprite+to+group.js", "title": "add a sprite to group" }, - { "file": "bring+a+child+to+top.js", "title": "bring a child to top" }, - { "file": "bring+a+group+to+top.js", "title": "bring a group to top" }, - { "file": "call+all.js", "title": "call all" }, - { "file": "create+group.js", "title": "create group" }, - { "file": "create+sprite+in+a+group.js", "title": "create sprite in a group" }, - { "file": "display+order.js", "title": "display order" }, - { "file": "for+each.js", "title": "for each" }, - { "file": "get+first.js", "title": "get first" }, - { "file": "group+as+layer.js", "title": "group as layer" }, - { "file": "group+transform+-+rotate.js", "title": "group transform - rotate" }, - { "file": "group+transform+-+tween.js", "title": "group transform - tween" }, - { "file": "group+transform.js", "title": "group transform" }, - { "file": "recyling.js", "title": "recyling" }, - { "file": "remove.js", "title": "remove" }, - { "file": "replace.js", "title": "replace" }, - { "file": "set+All.js", "title": "set All" }, - { "file": "sub+groups+-+group+length.js", "title": "sub groups - group length" }, - { "file": "swap+children+in+a+group.js", "title": "swap children in a group" } -], -"input": [ - { "file": "cursor+key+movement.js", "title": "cursor key movement" }, - { "file": "drag+several+sprites.js", "title": "drag several sprites" }, - { "file": "drag.js", "title": "drag" }, - { "file": "drop+limitation.js", "title": "drop limitation" }, - { "file": "follow+mouse.js", "title": "follow mouse" }, - { "file": "game+scale.js", "title": "game scale" }, - { "file": "key.js", "title": "key" }, - { "file": "keyboard+hotkeys.js", "title": "keyboard hotkeys" }, - { "file": "keyboard+justpressed.js", "title": "keyboard justpressed" }, - { "file": "keyboard.js", "title": "keyboard" }, - { "file": "motion+lock+-+horizontal.js", "title": "motion lock - horizontal" }, - { "file": "motion+lock+-+vertical.js", "title": "motion lock - vertical" }, - { "file": "multi+touch.js", "title": "multi touch" }, - { "file": "override+default+controls.js", "title": "override default controls" }, - { "file": "pixel+perfect+click+detection.js", "title": "pixel perfect click detection" }, - { "file": "pixelpick+-+scrolling+effect.js", "title": "pixelpick - scrolling effect" }, - { "file": "pixelpick+-+spritesheet.js", "title": "pixelpick - spritesheet" }, - { "file": "snap+on+drag.js", "title": "snap on drag" } -], -"loader": [ - { "file": "pick+images+from+cache.js", "title": "pick images from cache" } -], -"misc": [ - { "file": "net.js", "title": "net" }, - { "file": "random+generators.js", "title": "random generators" }, - { "file": "repeatable+random+numbers.js", "title": "repeatable random numbers" } -], -"particles": [ - { "file": "click+burst.js", "title": "click burst" }, - { "file": "collision.js", "title": "collision" }, - { "file": "diamond+burst.js", "title": "diamond burst" }, - { "file": "no+rotation.js", "title": "no rotation" }, - { "file": "random+sprite.js", "title": "random sprite" }, - { "file": "when+particles+collide.js", "title": "when particles collide" }, - { "file": "zero+gravity.js", "title": "zero gravity" } -], -"physics": [ - { "file": "accelerate+to+pointer.js", "title": "accelerate to pointer" }, - { "file": "angle+between.js", "title": "angle between" }, - { "file": "angle+to+pointer.js", "title": "angle to pointer" }, - { "file": "angular+acceleration.js", "title": "angular acceleration" }, - { "file": "angular+velocity.js", "title": "angular velocity" }, - { "file": "mass+velocity+test.js", "title": "mass velocity test" }, - { "file": "move+towards+object.js", "title": "move towards object" }, - { "file": "multi+angle+to+pointer.js", "title": "multi angle to pointer" }, - { "file": "quadtree+-+collision+infos.js", "title": "quadtree - collision infos" }, - { "file": "quadtree+-+ids.js", "title": "quadtree - ids" }, - { "file": "shoot+the+pointer.js", "title": "shoot the pointer" }, - { "file": "sprite+bounds.js", "title": "sprite bounds" } -], -"sprites": [ - { "file": "add+a+sprite.js", "title": "add a sprite" }, - { "file": "add+several+sprites.js", "title": "add several sprites" }, - { "file": "collide+world+bounds.js", "title": "collide world bounds" }, - { "file": "destroy.js", "title": "destroy" }, - { "file": "dynamic+crop.js", "title": "dynamic crop" }, - { "file": "extending+sprite+demo+1.js", "title": "extending sprite demo 1" }, - { "file": "extending+sprite+demo+2.js", "title": "extending sprite demo 2" }, - { "file": "horizontal+crop.js", "title": "horizontal crop" }, - { "file": "move+a+sprite.js", "title": "move a sprite" }, - { "file": "out+of+bounds.js", "title": "out of bounds" }, - { "file": "scale+a+sprite.js", "title": "scale a sprite" }, - { "file": "shared+sprite+textures.js", "title": "shared sprite textures" }, - { "file": "sprite+rotation.js", "title": "sprite rotation" }, - { "file": "spritesheet.js", "title": "spritesheet" }, - { "file": "vertical+crop.js", "title": "vertical crop" } -], -"text": [ - { "file": "bitmap+fonts.js", "title": "bitmap fonts" }, - { "file": "hello+arial.js", "title": "hello arial" }, - { "file": "kern+of+duty.js", "title": "kern of duty" }, - { "file": "remove+text.js", "title": "remove text" }, - { "file": "text+stroke.js", "title": "text stroke" } -], -"tile sprites": [ - { "file": "animated+tiling+sprite.js", "title": "animated tiling sprite" }, - { "file": "tiling+sprite.js", "title": "tiling sprite" } -], -"tilemaps": [ - { "file": "Sci-Fly.js", "title": "Sci-Fly" }, - { "file": "fill+tiles.js", "title": "fill tiles" }, - { "file": "mapcollide.js", "title": "mapcollide" }, - { "file": "mario.js", "title": "mario" }, - { "file": "mariotogether.js", "title": "mariotogether" }, - { "file": "paint+tiles.js", "title": "paint tiles" }, - { "file": "randomise+tiles.js", "title": "randomise tiles" }, - { "file": "replace+tiles.js", "title": "replace tiles" }, - { "file": "supermario.js", "title": "supermario" }, - { "file": "supermario2.js", "title": "supermario2" }, - { "file": "swap+tiles.js", "title": "swap tiles" }, - { "file": "wip1.js", "title": "wip1" }, - { "file": "wip2.js", "title": "wip2" }, - { "file": "wip3.js", "title": "wip3" }, - { "file": "wip4.js", "title": "wip4" } -], -"tweens": [ - { "file": "bounce.js", "title": "bounce" }, - { "file": "bubbles.js", "title": "bubbles" }, - { "file": "chained+tweens.js", "title": "chained tweens" }, - { "file": "combined+tweens.js", "title": "combined tweens" }, - { "file": "easing+spritesheets.js", "title": "easing spritesheets" }, - { "file": "easing.js", "title": "easing" }, - { "file": "fading+in+a+sprite.js", "title": "fading in a sprite" }, - { "file": "pause+tween.js", "title": "pause tween" }, - { "file": "tween+several+properties.js", "title": "tween several properties" } -], -"world": [ - { "file": "fixed+to+camera.js", "title": "fixed to camera" }, - { "file": "move+around+world.js", "title": "move around world" } -] + "animation": [ + { + "file": "change+texture+on+click.js", + "title": "change texture on click" + }, + { + "file": "local+json+object.js", + "title": "local json object" + }, + { + "file": "looped+animation.js", + "title": "looped animation" + }, + { + "file": "multiple+anims.js", + "title": "multiple anims" + }, + { + "file": "sprite+sheet.js", + "title": "sprite sheet" + }, + { + "file": "texture+packer+json+hash.js", + "title": "texture packer json hash" + } + ], + "audio": [ + { + "file": "loop.js", + "title": "loop" + }, + { + "file": "play+music.js", + "title": "play music" + } + ], + "basics": [ + { + "file": "01+-+load+an+image.js", + "title": "01 - load an image" + } + ], + "buttons": [ + { + "file": "action+on+click.js", + "title": "action on click" + }, + { + "file": "changing+the+frames.js", + "title": "changing the frames" + }, + { + "file": "rotated+buttons.js", + "title": "rotated buttons" + } + ], + "camera": [ + { + "file": "basic+follow.js", + "title": "basic follow" + }, + { + "file": "camera+cull.js", + "title": "camera cull" + }, + { + "file": "follow+styles.js", + "title": "follow styles" + }, + { + "file": "moving+the+camera.js", + "title": "moving the camera" + }, + { + "file": "world+sprite.js", + "title": "world sprite" + } + ], + "collision": [ + { + "file": "bounding+box.js", + "title": "bounding box" + }, + { + "file": "group+vs+group.js", + "title": "group vs group" + }, + { + "file": "larger+bounding+box.js", + "title": "larger bounding box" + }, + { + "file": "offset+bounding+box.js", + "title": "offset bounding box" + }, + { + "file": "sprite+tiles.js", + "title": "sprite tiles" + }, + { + "file": "sprite+vs+group.js", + "title": "sprite vs group" + }, + { + "file": "sprite+vs+sprite+custom.js", + "title": "sprite vs sprite custom" + }, + { + "file": "sprite+vs+sprite.js", + "title": "sprite vs sprite" + }, + { + "file": "transform.js", + "title": "transform" + }, + { + "file": "vertical+collision.js", + "title": "vertical collision" + } + ], + "display": [ + { + "file": "fullscreen.js", + "title": "fullscreen" + }, + { + "file": "graphics.js", + "title": "graphics" + }, + { + "file": "render+crisp.js", + "title": "render crisp" + } + ], + "games": [ + { + "file": "breakout.js", + "title": "breakout" + }, + { + "file": "invaders.js", + "title": "invaders" + }, + { + "file": "starstruck.js", + "title": "starstruck" + }, + { + "file": "tanks.js", + "title": "tanks" + } + ], + "geometry": [ + { + "file": "circle.js", + "title": "circle" + }, + { + "file": "line.js", + "title": "line" + }, + { + "file": "playing+with+points.js", + "title": "playing with points" + }, + { + "file": "rectangle.js", + "title": "rectangle" + }, + { + "file": "rotate+point.js", + "title": "rotate point" + } + ], + "groups": [ + { + "file": "add+a+sprite+to+group.js", + "title": "add a sprite to group" + }, + { + "file": "bring+a+child+to+top.js", + "title": "bring a child to top" + }, + { + "file": "bring+a+group+to+top.js", + "title": "bring a group to top" + }, + { + "file": "call+all.js", + "title": "call all" + }, + { + "file": "create+group.js", + "title": "create group" + }, + { + "file": "create+sprite+in+a+group.js", + "title": "create sprite in a group" + }, + { + "file": "display+order.js", + "title": "display order" + }, + { + "file": "for+each.js", + "title": "for each" + }, + { + "file": "get+first.js", + "title": "get first" + }, + { + "file": "group+as+layer.js", + "title": "group as layer" + }, + { + "file": "group+transform+-+rotate.js", + "title": "group transform - rotate" + }, + { + "file": "group+transform+-+tween.js", + "title": "group transform - tween" + }, + { + "file": "group+transform.js", + "title": "group transform" + }, + { + "file": "recyling.js", + "title": "recyling" + }, + { + "file": "remove.js", + "title": "remove" + }, + { + "file": "replace.js", + "title": "replace" + }, + { + "file": "set+All.js", + "title": "set All" + }, + { + "file": "sub+groups+-+group+length.js", + "title": "sub groups - group length" + }, + { + "file": "swap+children+in+a+group.js", + "title": "swap children in a group" + } + ], + "input": [ + { + "file": "cursor+key+movement.js", + "title": "cursor key movement" + }, + { + "file": "drag+several+sprites.js", + "title": "drag several sprites" + }, + { + "file": "drag.js", + "title": "drag" + }, + { + "file": "drop+limitation.js", + "title": "drop limitation" + }, + { + "file": "follow+mouse.js", + "title": "follow mouse" + }, + { + "file": "game+scale.js", + "title": "game scale" + }, + { + "file": "key.js", + "title": "key" + }, + { + "file": "keyboard+hotkeys.js", + "title": "keyboard hotkeys" + }, + { + "file": "keyboard+justpressed.js", + "title": "keyboard justpressed" + }, + { + "file": "keyboard.js", + "title": "keyboard" + }, + { + "file": "motion+lock+-+horizontal.js", + "title": "motion lock - horizontal" + }, + { + "file": "motion+lock+-+vertical.js", + "title": "motion lock - vertical" + }, + { + "file": "multi+touch.js", + "title": "multi touch" + }, + { + "file": "override+default+controls.js", + "title": "override default controls" + }, + { + "file": "pixel+perfect+click+detection.js", + "title": "pixel perfect click detection" + }, + { + "file": "pixelpick+-+scrolling+effect.js", + "title": "pixelpick - scrolling effect" + }, + { + "file": "pixelpick+-+spritesheet.js", + "title": "pixelpick - spritesheet" + }, + { + "file": "snap+on+drag.js", + "title": "snap on drag" + } + ], + "loader": [ + { + "file": "pick+images+from+cache.js", + "title": "pick images from cache" + } + ], + "misc": [ + { + "file": "net.js", + "title": "net" + }, + { + "file": "random+generators.js", + "title": "random generators" + }, + { + "file": "repeatable+random+numbers.js", + "title": "repeatable random numbers" + } + ], + "particles": [ + { + "file": "click+burst.js", + "title": "click burst" + }, + { + "file": "collision.js", + "title": "collision" + }, + { + "file": "diamond+burst.js", + "title": "diamond burst" + }, + { + "file": "no+rotation.js", + "title": "no rotation" + }, + { + "file": "random+sprite.js", + "title": "random sprite" + }, + { + "file": "when+particles+collide.js", + "title": "when particles collide" + }, + { + "file": "zero+gravity.js", + "title": "zero gravity" + } + ], + "physics": [ + { + "file": "accelerate+to+pointer.js", + "title": "accelerate to pointer" + }, + { + "file": "angle+between.js", + "title": "angle between" + }, + { + "file": "angle+to+pointer.js", + "title": "angle to pointer" + }, + { + "file": "angular+acceleration.js", + "title": "angular acceleration" + }, + { + "file": "angular+velocity.js", + "title": "angular velocity" + }, + { + "file": "mass+velocity+test.js", + "title": "mass velocity test" + }, + { + "file": "move+towards+object.js", + "title": "move towards object" + }, + { + "file": "multi+angle+to+pointer.js", + "title": "multi angle to pointer" + }, + { + "file": "quadtree+-+collision+infos.js", + "title": "quadtree - collision infos" + }, + { + "file": "quadtree+-+ids.js", + "title": "quadtree - ids" + }, + { + "file": "shoot+the+pointer.js", + "title": "shoot the pointer" + }, + { + "file": "sprite+bounds.js", + "title": "sprite bounds" + } + ], + "sprites": [ + { + "file": "add+a+sprite.js", + "title": "add a sprite" + }, + { + "file": "add+several+sprites.js", + "title": "add several sprites" + }, + { + "file": "collide+world+bounds.js", + "title": "collide world bounds" + }, + { + "file": "destroy.js", + "title": "destroy" + }, + { + "file": "dynamic+crop.js", + "title": "dynamic crop" + }, + { + "file": "extending+sprite+demo+1.js", + "title": "extending sprite demo 1" + }, + { + "file": "extending+sprite+demo+2.js", + "title": "extending sprite demo 2" + }, + { + "file": "horizontal+crop.js", + "title": "horizontal crop" + }, + { + "file": "move+a+sprite.js", + "title": "move a sprite" + }, + { + "file": "out+of+bounds.js", + "title": "out of bounds" + }, + { + "file": "scale+a+sprite.js", + "title": "scale a sprite" + }, + { + "file": "shared+sprite+textures.js", + "title": "shared sprite textures" + }, + { + "file": "sprite+rotation.js", + "title": "sprite rotation" + }, + { + "file": "spritesheet.js", + "title": "spritesheet" + }, + { + "file": "vertical+crop.js", + "title": "vertical crop" + } + ], + "text": [ + { + "file": "bitmap+fonts.js", + "title": "bitmap fonts" + }, + { + "file": "hello+arial.js", + "title": "hello arial" + }, + { + "file": "kern+of+duty.js", + "title": "kern of duty" + }, + { + "file": "remove+text.js", + "title": "remove text" + }, + { + "file": "text+stroke.js", + "title": "text stroke" + } + ], + "tile sprites": [ + { + "file": "animated+tiling+sprite.js", + "title": "animated tiling sprite" + }, + { + "file": "tiling+sprite.js", + "title": "tiling sprite" + } + ], + "tilemaps": [ + { + "file": "fill+tiles.js", + "title": "fill tiles" + }, + { + "file": "mapcollide.js", + "title": "mapcollide" + }, + { + "file": "mario.js", + "title": "mario" + }, + { + "file": "mariotogether.js", + "title": "mariotogether" + }, + { + "file": "paint+tiles.js", + "title": "paint tiles" + }, + { + "file": "randomise+tiles.js", + "title": "randomise tiles" + }, + { + "file": "replace+tiles.js", + "title": "replace tiles" + }, + { + "file": "sci+fly.js", + "title": "sci fly" + }, + { + "file": "supermario.js", + "title": "supermario" + }, + { + "file": "supermario2.js", + "title": "supermario2" + }, + { + "file": "swap+tiles.js", + "title": "swap tiles" + }, + { + "file": "wip1.js", + "title": "wip1" + }, + { + "file": "wip2.js", + "title": "wip2" + }, + { + "file": "wip3.js", + "title": "wip3" + }, + { + "file": "wip4.js", + "title": "wip4" + } + ], + "tweens": [ + { + "file": "bounce.js", + "title": "bounce" + }, + { + "file": "bubbles.js", + "title": "bubbles" + }, + { + "file": "chained+tweens.js", + "title": "chained tweens" + }, + { + "file": "combined+tweens.js", + "title": "combined tweens" + }, + { + "file": "easing+spritesheets.js", + "title": "easing spritesheets" + }, + { + "file": "easing.js", + "title": "easing" + }, + { + "file": "fading+in+a+sprite.js", + "title": "fading in a sprite" + }, + { + "file": "pause+tween.js", + "title": "pause tween" + }, + { + "file": "tween+several+properties.js", + "title": "tween several properties" + } + ], + "world": [ + { + "file": "fixed+to+camera.js", + "title": "fixed to camera" + }, + { + "file": "move+around+world.js", + "title": "move around world" + } + ] } \ No newline at end of file diff --git a/examples/_site/view_full.html b/examples/_site/view_full.html index 83d6c04ff..11eb14b02 100644 --- a/examples/_site/view_full.html +++ b/examples/_site/view_full.html @@ -9,7 +9,7 @@ @@ -193,4 +193,4 @@ - \ No newline at end of file + diff --git a/examples/_site/view_lite.html b/examples/_site/view_lite.html index a8d7e6794..2768996ca 100644 --- a/examples/_site/view_lite.html +++ b/examples/_site/view_lite.html @@ -9,7 +9,7 @@ @@ -119,4 +119,4 @@ - \ No newline at end of file + diff --git a/package.json b/package.json index d7fc476c8..27aeecbdf 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,7 @@ { "name": "Phaser", - "version": "1.0.7", - "description": "html5 game framework", - "main": "build/phaser.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, + "version": "1.1.0", + "description": "HTML5 game framework", "repository": { "type": "git", "url": "https://photonstorm@github.com/photonstorm/phaser.git" @@ -18,15 +14,13 @@ ], "author": "Richard Davey", "license": "MIT", - "readmeFilename": "README.md", - "gitHead": "1217bf4722768514fe15ff904dab59f848d146f4", "devDependencies": { "grunt": "~0.4.1", - "typescript": "~0.8.3", - "grunt-typescript": "~0.1.4", - "grunt-contrib-watch": "~0.3.1", - "grunt-contrib-connect": "~0.3.0", - "grunt-open": "~0.2.0", - "grunt-contrib-copy": "~0.4.1" + "grunt-contrib-concat": "~0.3.0", + "grunt-contrib-connect": "~0.5.0", + "grunt-contrib-copy": "~0.4.1", + "grunt-contrib-clean": "~0.5.0", + "grunt-contrib-uglify": "~0.2.4", + "lodash": "~2.2.1" } } diff --git a/src/Intro.js b/src/Intro.js index f260f9a98..908be5785 100644 --- a/src/Intro.js +++ b/src/Intro.js @@ -9,7 +9,7 @@ * * Phaser - http://www.phaser.io * -* v{version} - Built at: {buildDate} +* v<%= version %> - Built at: <%= buildDate %> * * By Richard Davey http://www.photonstorm.com @photonstorm * diff --git a/src/Phaser.js b/src/Phaser.js index d6be22ec4..639e1637f 100644 --- a/src/Phaser.js +++ b/src/Phaser.js @@ -7,10 +7,10 @@ /** * @namespace Phaser */ -var Phaser = Phaser || { +var Phaser = Phaser || { - VERSION: '1.1.0', - GAMES: [], + VERSION: '<%= version %>', + GAMES: [], AUTO: 0, CANVAS: 1, WEBGL: 2, @@ -39,4 +39,4 @@ var Phaser = Phaser || { PIXI.InteractionManager = function (dummy) { // We don't need this in Pixi, so we've removed it to save space // however the Stage object expects a reference to it, so here is a dummy entry. -}; \ No newline at end of file +}; diff --git a/src/core/Game.js b/src/core/Game.js index 47acbb98a..83d0e0ded 100644 --- a/src/core/Game.js +++ b/src/core/Game.js @@ -32,7 +32,7 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant if (typeof transparent == 'undefined') { transparent = false; } if (typeof antialias == 'undefined') { antialias = true; } - + /** * @property {number} id - Phaser Game ID (for when Pixi supports multiple instances). */ @@ -251,7 +251,7 @@ Phaser.Game.prototype = { /** * Initialize engine sub modules and start the game. - * + * * @method Phaser.Game#boot * @protected */ @@ -315,10 +315,13 @@ Phaser.Game.prototype = { console.log('%cPhaser ' + Phaser.VERSION + ' initialized. Rendering to WebGL', 'color: #ffff33; background: #000000'); } - if (Phaser.VERSION.substr(-5) == '-beta') - { - console.warn('You are using a beta version of Phaser. Some things may not work.'); - } + var pos = Phaser.VERSION.indexOf('-'); + var versionQualifier = (pos >= 0) ? Phaser.VERSION.substr(pos + 1) : null; + if (versionQualifier) + { + var article = ['a', 'e', 'i', 'o', 'u', 'y'].indexOf(versionQualifier.charAt(0)) >= 0 ? 'an' : 'a'; + console.warn('You are using %s %s version of Phaser. Some things may not work.', article, versionQualifier); + } this.isRunning = true; this._loadComplete = false; @@ -329,10 +332,10 @@ Phaser.Game.prototype = { } }, - + /** * Checks if the device is capable of using the requested renderer and sets it up or an alternative if not. - * + * * @method Phaser.Game#setUpRenderer * @protected */ @@ -369,7 +372,7 @@ Phaser.Game.prototype = { /** * Called when the load has finished, after preload was run. - * + * * @method Phaser.Game#loadComplete * @protected */ @@ -383,7 +386,7 @@ Phaser.Game.prototype = { /** * The core game loop. - * + * * @method Phaser.Game#update * @protected * @param {number} time - The current time as provided by RequestAnimationFrame. @@ -418,7 +421,7 @@ Phaser.Game.prototype = { /** * Nuke the entire game from orbit - * + * * @method Phaser.Game#destroy */ destroy: function () { diff --git a/tasks/examples.js b/tasks/examples.js new file mode 100644 index 000000000..d9bdf8821 --- /dev/null +++ b/tasks/examples.js @@ -0,0 +1,49 @@ +var path = require('path'); +var _ = require('lodash'); + +function pathToArray(parts) { + var part = parts.shift(); + if (parts.length > 0) { + var obj = {}; + obj[part] = pathToArray(parts); + return obj; + } else { + return part; + } +} + +module.exports = function(grunt) { + grunt.registerMultiTask('examples', 'Build examples site.', function() { + var options = this.options({ + base: '', + excludes: [] + }); + + this.files.forEach(function(f) { + var results = {}; + f.src.filter(function(filepath) { + if (!grunt.file.exists(filepath)) { + grunt.log.warn('Source file "' + filepath + '" not found.'); + return false; + } else { + filepath = path.relative(options.base, filepath); + return options.excludes.every(function(dir) { + return filepath.indexOf(dir + '/') < 0; + }); + } + }).map(function(filepath) { + return pathToArray(path.relative(options.base, filepath).split('/')); + }).forEach(function(parts) { + _.merge(results, parts, function(a, b) { + var example = { + file: encodeURIComponent(b).replace(/%20/g, '+'), + title: b.substr(0, b.length - 3) + }; + return _.isArray(a) ? a.concat(example) : [example]; + }); + }); + + grunt.file.write(f.dest, JSON.stringify(results, null, ' ')); + }); + }); +}; diff --git a/tasks/umd.js b/tasks/umd.js new file mode 100644 index 000000000..428d44a14 --- /dev/null +++ b/tasks/umd.js @@ -0,0 +1,35 @@ +var umdBefore = [ + '!function(root, factory) {', + ' if (typeof define === "function" && define.amd) {', + ' define(factory);', + ' } else if (typeof exports === "object") {', + ' module.exports = factory();', + ' } else {', + ' root.Phaser = factory();', + ' }', + '}(this, function() {' +].join('\n'); + +var umdAfter = [ + ' return Phaser;', + '});' +].join('\n'); + +module.exports = function(grunt) { + grunt.registerMultiTask('umd', 'Create an UMD wrapper.', function() { + this.files.forEach(function(f) { + var src = umdBefore + '\n' + f.src.filter(function(filepath) { + if (!grunt.file.exists(filepath)) { + grunt.log.warn('Source file "' + filepath + '" not found.'); + return false; + } else { + return true; + } + }).map(function(filepath) { + return grunt.file.read(filepath); + }).join('\n') + umdAfter; + + grunt.file.write(f.dest, src); + }); + }); +};