Starting work on Group.

This commit is contained in:
Richard Davey 2013-09-05 21:07:44 +01:00
parent b2fa345c9d
commit 0c97e8e151
9 changed files with 535 additions and 490 deletions

View file

@ -3,6 +3,66 @@
{
"selected_items":
[
[
"refre",
"refreshRate"
],
[
"my",
"my3d"
],
[
"myfx",
"myfx"
],
[
"canv",
"canvasToConsole"
],
[
"_",
"_iNext"
],
[
"nex",
"nextNode"
],
[
"node1",
"node1Prev"
],
[
"node2",
"node2Next"
],
[
"_i",
"_iPrev"
],
[
"rad",
"radToDeg"
],
[
"callb",
"callbackContext (variable)"
],
[
"callbac",
"callbackContext"
],
[
"not",
"notifyCallback"
],
[
"pro",
"processCallback"
],
[
"quad",
"quadTreeID"
],
[
"ver",
"verticalMidpoint"
@ -59,10 +119,6 @@
"_o",
"_oy"
],
[
"_",
"_y (variable)"
],
[
"scal",
"scaleY"
@ -458,114 +514,41 @@
[
"con",
"consts"
],
[
"c",
"consts"
],
[
"class",
"classname"
],
[
"clas",
"classname"
],
[
"output",
"output_file"
],
[
"str_re",
"str_replace"
],
[
"input",
"input_dir"
],
[
"back",
"background-size"
],
[
"wait",
"waitingHelpscreen"
],
[
"juke",
"jukebox"
],
[
"jukeb",
"jukeboxPP"
],
[
"Beak",
"BeakerGameStartGameHook"
],
[
"Bea",
"BeakerGameStartGameHook"
],
[
"crea",
"createHD"
],
[
"whee",
"wheelUp"
]
]
},
"buffers":
[
{
"file": "src/physics/arcade/ArcadePhysics.js",
"file": "examples/consoleBanner2.php",
"settings":
{
"buffer_size": 15164,
"line_ending": "Windows",
"name": "Phaser.Physics.Arcade = function (game) {"
}
},
{
"file": "src/physics/arcade/Body.js",
"settings":
{
"buffer_size": 5199,
"buffer_size": 2371,
"line_ending": "Windows"
}
},
{
"file": "examples/quadtree.php",
"file": "/D/wamp/www/consoledemo/index.html",
"settings":
{
"buffer_size": 1953,
"buffer_size": 8399,
"line_ending": "Windows"
}
},
{
"file": "src/core/Game.js",
"file": "/D/wamp/www/consoledemo/src/codef_scrolltext.js",
"settings":
{
"buffer_size": 9013,
"line_ending": "Windows"
"buffer_size": 8518,
"line_ending": "Unix"
}
},
{
"file": "src/math/QuadTree.js",
"file": "/D/wamp/www/consoledemo/src/codef_core.js",
"settings":
{
"buffer_size": 6524,
"line_ending": "Windows"
}
},
{
"file": "src/utils/Debug.js",
"settings":
{
"buffer_size": 15959,
"line_ending": "Windows"
"buffer_size": 26037,
"line_ending": "Unix"
}
}
],
@ -597,24 +580,42 @@
},
"file_history":
[
"/D/wamp/www/phaser/src/geom/Rectangle.js",
"/D/wamp/www/phaser/src/gameobjects/Sprite.js",
"/D/wamp/www/consoledemo/src/codef_tween.js",
"/D/wamp/www/consoledemo/src/codef_3d.js",
"/D/wamp/www/consoledemo/src/codef_starfield.js",
"/D/JavaScript/codef/tutorials/40_starfield/index.html",
"/D/JavaScript/codef/tutorials/41_starfield/index.html",
"/D/wamp/www/phaser/src/physics/arcade/Body.js",
"/D/wamp/www/phaser/TS Source/display/DynamicTexture.js",
"/D/wamp/www/phaser/TS Source/utils/ColorUtils.ts",
"/D/wamp/www/phaser/src/pixi/renderers/canvas/CanvasRenderer.js",
"/D/wamp/www/phaser/src/pixi/display/DisplayObjectContainer.js",
"/D/wamp/www/phaser/src/core/World.js",
"/D/wamp/www/phaser/TS Source/display/DynamicTexture.ts",
"/D/wamp/www/phaser/src/gameobjects/GameObjectFactory.js",
"/D/wamp/www/phaser/src/core/Game.js",
"/D/wamp/www/phaser/src/physics/arcade/ArcadePhysics.js",
"/D/wamp/www/phaser/src/gameobjects/Sprite.js",
"/D/wamp/www/phaser/TS Source/gameobjects/Events.js",
"/D/wamp/www/phaser/TS Source/input/InputHandler.js",
"/D/wamp/www/phaser/src/input/Input.js",
"/D/wamp/www/phaser/src/input/Pointer.js",
"/D/wamp/www/phaser/src/utils/Debug.js",
"/D/wamp/www/phaser/src/math/QuadTree.js",
"/D/wamp/www/phaser/examples/motion1.php",
"/D/wamp/www/phaser/src/geom/Rectangle.js",
"/D/wamp/www/phaser/examples/js.php",
"/D/wamp/www/phaser/todo/phaser clean up/Collision.js",
"/D/wamp/www/phaser/todo/physics/Collision.js",
"/D/wamp/www/phaser/src/core/Game.js",
"/D/wamp/www/phaser/src/time/Time.js",
"/D/wamp/www/phaser/src/loader/Cache.js",
"/D/wamp/www/phaser/src/animation/AnimationManager.js",
"/D/wamp/www/phaser/src/animation/Frame.js",
"/D/wamp/www/phaser/src/utils/Debug.js",
"/D/wamp/www/phaser/src/tween/Tween.js",
"/D/wamp/www/phaser/src/pixi/display/MovieClip.js",
"/D/wamp/www/phaser/src/animation/Animation.js",
"/D/wamp/www/pixi.js/examples/example 10 - Text/index.html",
"/D/wamp/www/physicsRus/test2.html",
"/D/wamp/www/phaser/src/gameobjects/GameObjectFactory.js",
"/D/wamp/www/phaser/examples/text3.php",
"/D/wamp/www/phaser/src/gameobjects/Text.js",
"/D/wamp/www/phaser/src/pixi/text/Text.js",
@ -636,7 +637,6 @@
"/D/wamp/www/phaser/src/pixi/textures/Texture.js",
"/D/wamp/www/phaser/src/gameobjects/TileSprite.js",
"/D/wamp/www/phaser/examples/get_bounds.php",
"/D/wamp/www/phaser/src/pixi/renderers/canvas/CanvasRenderer.js",
"/D/wamp/www/phaser/src/pixi/display/Sprite.js",
"/D/wamp/www/phaser/examples/tilesprite1.php",
"/D/wamp/www/phaser/src/utils/Utils.js",
@ -655,11 +655,9 @@
"/D/wamp/www/phaser/src/sound/Sound.js",
"/D/wamp/www/phaser/TS Source/sound/Sound.ts",
"/D/wamp/www/phaser/TS Source/sound/SoundManager.js",
"/D/wamp/www/phaser/src/math/QuadTree.js",
"/D/wamp/www/phaser/TS Source/math/QuadTree.js",
"/D/wamp/www/phaser/src/pixi/display/Stage.js",
"/D/wamp/www/phaser/examples/camera_cull1.php",
"/D/wamp/www/phaser/src/pixi/display/DisplayObjectContainer.js",
"/D/wamp/www/phaser/src/pixi/display/DisplayObject.js",
"/D/wamp/www/bbc-wolfblood/assets/1024/help/help_titles.json",
"/D/wamp/www/phaser/src/math/LinkedList.js",
@ -672,7 +670,6 @@
"/D/wamp/www/pixi.js/examples/example 6 - Interactivity/index.html",
"/D/wamp/www/phaser/src/math/Math.js",
"/D/wamp/www/phaser/src/geom/Point.js",
"/D/wamp/www/phaser/src/input/Input.js",
"/D/wamp/www/phaser/TS Source/gameobjects/TransformManager.ts",
"/D/wamp/www/phaser/TS Source/utils/SpriteUtils.ts",
"/D/wamp/www/phaser/TS Source/utils/SpriteUtils.js",
@ -682,7 +679,6 @@
"/D/wamp/www/phaser/TS Source/utils/DebugUtils.js",
"/D/wamp/www/phaser/TS Source/renderers/canvas/SpriteRenderer.ts",
"/D/wamp/www/phaser/examples/input1.php",
"/D/wamp/www/phaser/src/input/Pointer.js",
"/D/wamp/www/phaser/src/input/Mouse.js",
"/D/wamp/www/phaser/src/input/Touch.js",
"/D/wamp/www/phaser/src/input/Keyboard.js",
@ -711,20 +707,7 @@
"/D/wamp/www/phaser/TS Source/tweens/Tween.ts",
"/D/wamp/www/phaser/TS Source/tweens/TweenManager.ts",
"/D/wamp/www/phaser/src/tween/TweenManager.js",
"/C/Users/rich/Desktop/game.js",
"/D/wamp/www/phaser/TS Source/animation/Animation.js",
"/D/wamp/www/phaser/TS Source/animation/AnimationManager.js",
"/D/wamp/www/phaser/TS Source/gameobjects/Sprite.js",
"/D/wamp/www/phaser/src/system/RequestAnimationFrame.js",
"/D/wamp/www/phaser/src/pixi/textures/BaseTexture.js",
"/D/wamp/www/phaser/src/pixi/loaders/ImageLoader.js",
"/D/wamp/www/phaser/src/animation/FrameData.js",
"/D/wamp/www/phaser/src/pixi/loaders/SpriteSheetLoader.js",
"/D/wamp/www/phaser/examples/assets/sprites/running_bot.json",
"/D/wamp/www/pixi.js/examples/example 2 - SpriteSheet/index.html",
"/D/wamp/www/pixi.js/examples/example 3 - MovieClip/index.html",
"/D/wamp/www/pixi.js/examples/example 3 - MovieClip/SpriteSheet.json",
"/D/wamp/www/phaser/examples/assets/sprites/pixi_monsters.json"
"/C/Users/rich/Desktop/game.js"
],
"find":
{
@ -732,9 +715,10 @@
},
"find_in_files":
{
"height": 90.0,
"height": 0.0,
"where_history":
[
"D:\\wamp\\www\\phaser\\src\\input",
"D:\\wamp\\www\\phaser\\src\\physics\\advanced",
"D:\\wamp\\www\\phaser\\src\\pixi",
"D:\\wamp\\www\\phaser\\src\\input",
@ -761,6 +745,35 @@
"case_sensitive": true,
"find_history":
[
"launch",
"font1",
"480",
"640",
"http://codef.santo.fr/codef",
"%c ",
"s",
"line",
"node2",
"node1",
"Prev",
"Next",
"nextPrev",
"var ",
"nameNext",
"node: ",
"nameFirst",
"first",
"Phaser.Touch_OVERRIDES_MOUSE",
"Phaser.Mouse_TOUCH_COMBINE",
"Phaser.Mouse_OVERRIDES_TOUCH",
":GameObject",
":number",
"public ",
"\n ",
"public ",
": number",
"public ",
"left",
"1",
"8",
"x",
@ -859,36 +872,7 @@
"this._dirty",
"X",
"x",
"X",
"x",
"this._",
"this._y",
"this._x",
"x",
"updateOnVisible",
"updateTransform",
"worldTransform",
"world",
"s.",
"actual",
"worldTransform",
"getLocalPosition",
"worldTransform",
".a",
".",
"var ",
"displayObject",
"sprite",
"Micro",
"x",
"getLocalPosition",
"this.global",
"target.view",
"_width",
"key",
"worldView",
"DebugUtils.",
"Phaser.DebugUtils"
"X"
],
"highlight": true,
"in_selection": false,
@ -896,6 +880,13 @@
"regex": false,
"replace_history":
[
"%c ",
"child2",
"child1",
"Phaser.Input.TOUCH_OVERRIDES_MOUSE",
"Phaser.Input.MOUSE_TOUCH_COMBINE",
"Phaser.Input.MOUSE_OVERRIDES_TOUCH",
"",
"maxLevels",
"maxObjects",
"this.nodes",
@ -979,282 +970,23 @@
"groups":
[
{
"selected": 0,
"selected": 1,
"sheets":
[
{
"buffer": 0,
"file": "src/physics/arcade/ArcadePhysics.js",
"file": "examples/consoleBanner2.php",
"settings":
{
"buffer_size": 15164,
"buffer_size": 2371,
"regions":
{
},
"selection":
[
[
2843,
2843
]
],
"settings":
{
"auto_name": "Phaser.Physics.Arcade = function (game) {",
"codeintel": true,
"codeintel_config":
{
"JavaScript":
{
"codeintel_max_recursive_dir_depth": 2,
"codeintel_scan_files_in_project": false,
"javascriptExtraPaths":
[
]
},
"PHP":
{
"codeintel_max_recursive_dir_depth": 5,
"codeintel_scan_files_in_project": false,
"phpExtraPaths":
[
]
},
"Python":
{
"env":
{
}
}
},
"codeintel_enabled_languages":
[
"JavaScript",
"Mason",
"XBL",
"XUL",
"RHTML",
"SCSS",
"Python",
"HTML",
"Ruby",
"Python3",
"XML",
"Sass",
"XSLT",
"Django",
"HTML5",
"Perl",
"CSS",
"Twig",
"Less",
"Smarty",
"Node.js",
"Tcl",
"TemplateToolkit",
"PHP"
],
"codeintel_live": true,
"codeintel_live_enabled_languages":
[
"JavaScript",
"Mason",
"XBL",
"XUL",
"RHTML",
"SCSS",
"Python",
"HTML",
"Ruby",
"Python3",
"XML",
"Sass",
"XSLT",
"Django",
"HTML5",
"Perl",
"CSS",
"Twig",
"Less",
"Smarty",
"Node.js",
"Tcl",
"TemplateToolkit",
"PHP"
],
"codeintel_max_recursive_dir_depth": 10,
"codeintel_scan_exclude_dir":
{
"JavaScript":
[
"/build/",
"/min/"
]
},
"codeintel_scan_files_in_project": true,
"codeintel_selected_catalogs":
[
"PyWin32",
"jQuery",
"Rails"
],
"codeintel_snippets": true,
"codeintel_syntax_map":
{
"Python Django": "Python"
},
"sublime_auto_complete": true,
"syntax": "Packages/JavaScript/JavaScript.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 1118.0,
"zoom_level": 1.0
},
"type": "text"
},
{
"buffer": 1,
"file": "src/physics/arcade/Body.js",
"settings":
{
"buffer_size": 5199,
"regions":
{
},
"selection":
[
[
2478,
2478
]
],
"settings":
{
"codeintel": true,
"codeintel_config":
{
"JavaScript":
{
"codeintel_max_recursive_dir_depth": 2,
"codeintel_scan_files_in_project": false,
"javascriptExtraPaths":
[
]
},
"PHP":
{
"codeintel_max_recursive_dir_depth": 5,
"codeintel_scan_files_in_project": false,
"phpExtraPaths":
[
]
},
"Python":
{
"env":
{
}
}
},
"codeintel_enabled_languages":
[
"JavaScript",
"Mason",
"XBL",
"XUL",
"RHTML",
"SCSS",
"Python",
"HTML",
"Ruby",
"Python3",
"XML",
"Sass",
"XSLT",
"Django",
"HTML5",
"Perl",
"CSS",
"Twig",
"Less",
"Smarty",
"Node.js",
"Tcl",
"TemplateToolkit",
"PHP"
],
"codeintel_live": true,
"codeintel_live_enabled_languages":
[
"JavaScript",
"Mason",
"XBL",
"XUL",
"RHTML",
"SCSS",
"Python",
"HTML",
"Ruby",
"Python3",
"XML",
"Sass",
"XSLT",
"Django",
"HTML5",
"Perl",
"CSS",
"Twig",
"Less",
"Smarty",
"Node.js",
"Tcl",
"TemplateToolkit",
"PHP"
],
"codeintel_max_recursive_dir_depth": 10,
"codeintel_scan_exclude_dir":
{
"JavaScript":
[
"/build/",
"/min/"
]
},
"codeintel_scan_files_in_project": true,
"codeintel_selected_catalogs":
[
"PyWin32",
"jQuery",
"Rails"
],
"codeintel_snippets": true,
"codeintel_syntax_map":
{
"Python Django": "Python"
},
"sublime_auto_complete": true,
"syntax": "Packages/JavaScript/JavaScript.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 1818.0,
"zoom_level": 1.0
},
"type": "text"
},
{
"buffer": 2,
"file": "examples/quadtree.php",
"settings":
{
"buffer_size": 1953,
"regions":
{
},
"selection":
[
[
1078,
1078
524,
536
]
],
"settings":
@ -1365,25 +1097,25 @@
"syntax": "Packages/PHP/PHP.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 630.0,
"translation.y": 144.0,
"zoom_level": 1.0
},
"type": "text"
},
{
"buffer": 3,
"file": "src/core/Game.js",
"buffer": 1,
"file": "/D/wamp/www/consoledemo/index.html",
"settings":
{
"buffer_size": 9013,
"buffer_size": 8399,
"regions":
{
},
"selection":
[
[
6794,
6794
6153,
6153
]
],
"settings":
@ -1491,28 +1223,29 @@
"Python Django": "Python"
},
"sublime_auto_complete": true,
"syntax": "Packages/JavaScript/JavaScript.tmLanguage"
"syntax": "Packages/HTML/HTML.tmLanguage",
"translate_tabs_to_spaces": false
},
"translation.x": 0.0,
"translation.y": 5315.0,
"translation.y": 2092.0,
"zoom_level": 1.0
},
"type": "text"
},
{
"buffer": 4,
"file": "src/math/QuadTree.js",
"buffer": 2,
"file": "/D/wamp/www/consoledemo/src/codef_scrolltext.js",
"settings":
{
"buffer_size": 6524,
"buffer_size": 8518,
"regions":
{
},
"selection":
[
[
5376,
5376
1956,
1956
]
],
"settings":
@ -1624,25 +1357,25 @@
"translate_tabs_to_spaces": false
},
"translation.x": 0.0,
"translation.y": 3240.0,
"translation.y": 701.0,
"zoom_level": 1.0
},
"type": "text"
},
{
"buffer": 5,
"file": "src/utils/Debug.js",
"buffer": 3,
"file": "/D/wamp/www/consoledemo/src/codef_core.js",
"settings":
{
"buffer_size": 15959,
"buffer_size": 26037,
"regions":
{
},
"selection":
[
[
2452,
2452
3147,
3147
]
],
"settings":
@ -1750,12 +1483,10 @@
"Python Django": "Python"
},
"sublime_auto_complete": true,
"syntax": "Packages/JavaScript/JavaScript.tmLanguage",
"tab_size": 4,
"translate_tabs_to_spaces": true
"syntax": "Packages/JavaScript/JavaScript.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 1620.0,
"translation.y": 972.0,
"zoom_level": 1.0
},
"type": "text"

BIN
examples/assets/bd/back.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -14,84 +14,63 @@
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
var game = new Phaser.Game(50, 50, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
// game.load.image('piccie', 'assets/sprites/phaser_tiny.png');
game.load.image('piccie', 'assets/sprites/phaser_tiny.png');
// game.load.image('piccie', 'assets/sprites/carrot.png');
// game.load.image('piccie', 'assets/sprites/phaser-dude.png');
game.load.image('piccie', 'assets/pics/atari_fujilogo.png');
// game.load.image('piccie', 'assets/pics/atari_fujilogo.png');
}
var canvas;
var context;
var logo;
function create() {
var img = game.add.sprite(0, 0, 'piccie');
logo = game.add.sprite(0, 0, 'piccie');
canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
context = canvas.getContext('2d');
context.drawImage(game.cache.getImage('piccie'), 0, 0);
var result = '';
for (var y = 0; y < img.height; y++)
{
var line = '';
var css = '';
var previousColor = '';
for (var x = 0; x < img.width; x++)
{
var c = context.getImageData(x, y, 1, 1);
var s = "#" + colorToHex(c.data[0]) + colorToHex(c.data[1]) + colorToHex(c.data[2]);
if (s == previousColor)
{
line = line + ' ';
}
else
{
line = line + '%c ';
css = css + "'background: " + s + "', ";
previousColor = s;
}
}
css = css.substr(0, css.length - 2);
result = result + "console.log('" + line + "', " + css + ");\n";
}
document.getElementById('output').innerHTML = result;
logo.body.velocity = 10;
}
/**
* Return a string containing a hex representation of the given color
*
* @method colorToHexstring
* @param {Number} color The color channel to get the hex value for, must be a value between 0 and 255)
* @return {String} A string of length 2 characters, i.e. 255 = FF, 0 = 00
*/
function colorToHex(color) {
return "0123456789ABCDEF".charAt((color - (color % 16)) / 16) + "0123456789ABCDEF".charAt(color % 16);
}
var digits = "0123456789ABCDEF";
function canvasToConsole() {
var lsd = color % 16;
var msd = (color - lsd) / 16;
console.clear();
var hexified = digits.charAt(msd) + digits.charAt(lsd);
for (var y = 0; y < game.height; y++)
{
// var line = '';
var c = [];
var previousColor = '';
return hexified;
for (var x = 0; x < game.width; x++)
{
var rgb = game.renderer.context.getImageData(x, y, 1, 1);
var s = "#" + colorToHex(rgb.data[0]) + colorToHex(rgb.data[1]) + colorToHex(rgb.data[2]);
c.push("'background: " + s + "'");
}
console.log('%c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c ',
c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9],
c[10], c[11], c[12], c[13], c[14], c[15], c[16], c[17], c[18], c[19],
c[20], c[21], c[22], c[23], c[24], c[25], c[26], c[27], c[28], c[29],
c[30], c[31], c[32], c[33], c[34], c[35], c[36], c[37], c[38], c[39],
c[40], c[41], c[42], c[43], c[44], c[45], c[46], c[47], c[48], c[49],
c[50]);
}
}
function update() {
canvasToConsole();
}
function render() {

View file

@ -0,0 +1,86 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(50, 30, Phaser.CANVAS, '', { preload: preload, create: create, update: update });
function preload() {
game.load.image('background', 'assets/bd/back2.png');
// game.load.image('piccie', 'assets/sprites/phaser_tiny.png');
game.load.image('scroller', 'assets/bd/scroller.png');
}
var back;
var logo;
var scroller;
var t = 0;
function create() {
back = game.add.sprite(0, 0, 'background');
scroller = game.add.sprite(50, 10, 'scroller');
// logo = game.add.sprite(0, 0, 'piccie');
back.body.moves = false;
// logo.body.velocity.setTo(1,1);
// logo.body.bounce.setTo(1, 1);
// logo.body.collideWorldBounds = true;
game.add.tween(back).to( { y: -60 }, 20000, Phaser.Easing.Linear.None, true, 0, 1000, true);
game.add.tween(scroller).to( { x: -700 }, 700*250, Phaser.Easing.Linear.None, true, 0, 1000);
}
function update() {
if (game.time.now > t)
{
canvasToConsole();
t = game.time.now + 1000;
}
back.y -= 1;
}
function canvasToConsole() {
console.clear();
for (var y = 0; y < game.height; y++)
{
var c = [];
for (var x = 0; x < game.width; x++)
{
var rgb = game.renderer.context.getImageData(x, y, 1, 1);
var s = "#" + colorToHex(rgb.data[0]) + colorToHex(rgb.data[1]) + colorToHex(rgb.data[2]);
c.push("background: " + s + "");
}
console.log('%c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c ', c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10], c[11], c[12], c[13], c[14], c[15], c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23], c[24], c[25], c[26], c[27], c[28], c[29], c[30], c[31], c[32], c[33], c[34], c[35], c[36], c[37], c[38], c[39], c[40], c[41], c[42], c[43], c[44], c[45], c[46], c[47], c[48], c[49]);
}
}
function colorToHex(color) {
return "0123456789ABCDEF".charAt((color - (color % 16)) / 16) + "0123456789ABCDEF".charAt(color % 16);
}
})();
</script>
</body>
</html>

237
src/core/Group.js Normal file
View file

@ -0,0 +1,237 @@
Phaser.Group = function (game, name) {
this.game = game;
this.name = name || '';
this._container = new PIXI.DisplayObjectContainer();
// Swap for proper access to stage
this.game.world._stage.addChild(this._container);
this.active = true;
this.exists = true;
/**
* Helper for sort.
*/
this._sortIndex = 'y';
};
Phaser.Group.prototype = {
add: function (child) {
if (child.group !== this)
{
child.group = this;
this._container.addChild(child);
}
return child;
},
addAt: function (child, index) {
if (child.group !== this)
{
child.group = this;
this._container.addChildAt(child, index);
}
return child;
},
getChildAt: function (index) {
return this._container.getChildAt(index);
},
createSprite: function (x, y, key, frame) {
var child = new Phaser.Sprite(this.game, x, y, key, frame);
this._container.addChild(child);
return child;
},
swap: function (child1, child2) {
return this.game.world.swapChildren(child1, child2);
},
bringToTop: function (child) {
// ?!
},
replace: function (newChild, oldChild) {
},
/**
* Call this function to sort the group according to a particular value and order.
* For example, to sort game objects for Zelda-style overlaps you might call
* <code>myGroup.sort("y",Group.ASCENDING)</code> at the bottom of your
* <code>State.update()</code> override. To sort all existing objects after
* a big explosion or bomb attack, you might call <code>myGroup.sort("exists",Group.DESCENDING)</code>.
*
* @param {string} index The <code>string</code> name of the member variable you want to sort on. Default value is "z".
* @param {number} order A <code>Group</code> constant that defines the sort order. Possible values are <code>Group.ASCENDING</code> and <code>Group.DESCENDING</code>. Default value is <code>Group.ASCENDING</code>.
*/
sort: function (index, order) {
// if (typeof index === "undefined") { index = 'z'; }
// if (typeof order === "undefined") { order = Phaser.Types.SORT_ASCENDING; }
// var _this = this;
// this._sortIndex = index;
// this._sortOrder = order;
// this.members.sort(function (a, b) {
// return _this.sortHandler(a, b);
// });
},
/**
* Helper function for the sort process.
*
* @param {Basic} Obj1 The first object being sorted.
* @param {Basic} Obj2 The second object being sorted.
*
* @return {number} An integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2).
*/
sortHandler: function (obj1, obj2) {
/*
if(!obj1 || !obj2) {
//console.log('null objects in sort', obj1, obj2);
return 0;
}
if(obj1[this._sortIndex] < obj2[this._sortIndex]) {
return this._sortOrder;
} else if(obj1[this._sortIndex] > obj2[this._sortIndex]) {
return -this._sortOrder;
}
return 0;
*/
},
setAll: function () {
},
callAll: function () {
},
forEach: function () {
},
forEachAlive: function () {
},
forEachDead: function () {
},
getFirstAlive: function () {
var endNode = this._container.last._iNext;
var currentNode = this._container.first;
do
{
if (currentNode.alive)
{
return currentNode;
}
currentNode = currentNode._iNext;
}
while (currentNode != endNode)
},
getFirstDead: function () {
var endNode = this._container.last._iNext;
var currentNode = this._container.first;
do
{
if (currentNode.alive == false)
{
return currentNode;
}
currentNode = currentNode._iNext;
}
while (currentNode != endNode)
},
count: function (alive, visible) {
var endNode = this._container.last._iNext;
var currentNode = this._container.first;
do
{
if (currentNode.alive)
{
return currentNode;
}
currentNode = currentNode._iNext;
}
while (currentNode != endNode)
}
countLiving: function () {
var total = 0;
var endNode = this._container.last._iNext;
var currentNode = this._container.first;
do
{
if (currentNode.alive)
{
total++;
}
currentNode = currentNode._iNext;
}
while (currentNode != endNode);
return total;
},
countDead: function () {
},
getRandom: function () {
},
remove: function (child) {
},
destroy: function () {
}
};
Object.defineProperty(Phaser.World.prototype, "visible", {
get: function () {
return this._container.visible;
},
set: function (value) {
this._container.visible = value;
},
enumerable: true,
configurable: true
});

View file

@ -5,7 +5,7 @@ Phaser.World = function (game) {
this._stage = new PIXI.Stage(0x000000);
this._container = new PIXI.DisplayObjectContainer();
this._container.name = 'R';
this._container.name = '_stage_root';
this._stage.addChild(this._container);
@ -105,12 +105,12 @@ Phaser.World.prototype = {
},
swapChildren: function (stage, child1, child2) {
swapChildren: function (child1, child2) {
if (child1 === child2 || !child1.parent || !child2.parent)
{
console.warn('You cannot swap a child with itself or swap un-parented children');
return;
return false;
}
// Cache the values
@ -119,8 +119,8 @@ Phaser.World.prototype = {
var child2Prev = child2._iPrev;
var child2Next = child2._iNext;
var endNode = stage.last._iNext;
var currentNode = stage.first;
var endNode = this._stage.last._iNext;
var currentNode = this._stage.first;
do
{
@ -159,10 +159,12 @@ Phaser.World.prototype = {
if (child1Prev) { child1Prev._iNext = child2; }
if (child2Next) { child2Next._iPrev = child1; }
return true;
}
else if (child2._iNext == child1)
{
// This is am upward (B to A) neighbour swap
// This is an upward (B to A) neighbour swap
child1._iNext = child2;
child1._iPrev = child2Prev;
child2._iNext = child1Next;
@ -170,6 +172,8 @@ Phaser.World.prototype = {
if (child2Prev) { child2Prev._iNext = child1; }
if (child1Next) { child2Next._iPrev = child2; }
return true;
}
else
{
@ -183,7 +187,12 @@ Phaser.World.prototype = {
if (child1Next) { child1Next._iPrev = child2; }
if (child2Prev) { child2Prev._iNext = child1; }
if (child2Next) { child2Next._iPrev = child1; }
return true;
}
return false;
}
};

View file

@ -95,7 +95,10 @@ Phaser.Physics.Arcade.Body.prototype = {
this.lastX = this.x;
this.lastY = this.y;
this.game.physics.updateMotion(this);
if (this.moves)
{
this.game.physics.updateMotion(this);
}
this.bounds.x = this.x;
this.bounds.y = this.y;