getBounds update.

This commit is contained in:
Richard Davey
2013-09-01 13:17:44 +01:00
parent 71b4cc532f
commit 7bdcbf5c2a
5 changed files with 325 additions and 167 deletions
+304 -165
View File
@@ -519,35 +519,43 @@
},
"buffers":
[
{
"file": "src/core/Game.js",
"settings":
{
"buffer_size": 9194,
"line_ending": "Windows"
}
},
{
"file": "src/gameobjects/Sprite.js",
"settings":
{
"buffer_size": 7942,
"buffer_size": 9167,
"line_ending": "Windows"
}
},
{
"file": "examples/camera5.php",
"file": "examples/camera4.php",
"settings":
{
"buffer_size": 1272,
"buffer_size": 1166,
"line_ending": "Windows"
}
},
{
"file": "examples/sprite3.php",
"file": "src/animation/Parser.js",
"settings":
{
"buffer_size": 1406,
"buffer_size": 8379,
"line_ending": "Windows"
}
},
{
"file": "src/animation/Frame.js",
"settings":
{
"buffer_size": 3046,
"line_ending": "Windows"
}
},
{
"file": "src/animation/AnimationManager.js",
"settings":
{
"buffer_size": 6598,
"line_ending": "Windows"
}
}
@@ -580,6 +588,9 @@
},
"file_history":
[
"/D/wamp/www/phaser/src/core/Game.js",
"/D/wamp/www/phaser/examples/sprite3.php",
"/D/wamp/www/phaser/examples/camera5.php",
"/D/wamp/www/phaser/src/utils/Debug.js",
"/D/wamp/www/phaser/src/pixi/InteractionManager.js",
"/D/wamp/www/pixi.js/examples/example 6 - Interactivity/index.html",
@@ -618,7 +629,6 @@
"/D/wamp/www/phaser/TS Source/input/InputManager.js",
"/D/wamp/www/phaser/TS Source/input/Keyboard.ts",
"/D/wamp/www/phaser/TS Source/input/Keyboard.js",
"/D/wamp/www/phaser/examples/sprite3.php",
"/D/wamp/www/phaser/src/pixi/primitives/Graphics.js",
"/D/wamp/www/pixi.js/examples/example 11 - RenderTexture/index.html",
"/D/wamp/www/phaser/src/pixi/textures/RenderTexture.js",
@@ -705,9 +715,7 @@
"/D/wamp/www/phaser/examples/point.html",
"/D/wamp/www/phaser/src/geom/Circle.js",
"/D/wamp/www/phaser/TS Source/utils/PointUtils.js",
"/D/wamp/www/phaser/TS Source/geom/Point.js",
"/D/wamp/www/phaser/TS Source/time/TimeManager.js",
"/D/wamp/www/phaser/TS Source/time/TimeManager.ts"
"/D/wamp/www/phaser/TS Source/geom/Point.js"
],
"find":
{
@@ -715,7 +723,7 @@
},
"find_in_files":
{
"height": 90.0,
"height": 0.0,
"where_history":
[
"D:\\wamp\\www\\phaser\\src\\pixi",
@@ -939,152 +947,23 @@
"groups":
[
{
"selected": 2,
"selected": 1,
"sheets":
[
{
"buffer": 0,
"file": "src/core/Game.js",
"settings":
{
"buffer_size": 9194,
"regions":
{
},
"selection":
[
[
8729,
8729
]
],
"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": 6325.0,
"zoom_level": 1.0
},
"type": "text"
},
{
"buffer": 1,
"file": "src/gameobjects/Sprite.js",
"settings":
{
"buffer_size": 7942,
"buffer_size": 9167,
"regions":
{
},
"selection":
[
[
4184,
4184
7118,
7118
]
],
"settings":
@@ -1197,25 +1076,155 @@
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
"translation.y": 2844.0,
"translation.y": 3579.0,
"zoom_level": 1.0
},
"type": "text"
},
{
"buffer": 1,
"file": "examples/camera4.php",
"settings":
{
"buffer_size": 1166,
"regions":
{
},
"selection":
[
[
1089,
1089
]
],
"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/PHP/PHP.tmLanguage",
"translate_tabs_to_spaces": false
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"type": "text"
},
{
"buffer": 2,
"file": "examples/camera5.php",
"file": "src/animation/Parser.js",
"settings":
{
"buffer_size": 1272,
"buffer_size": 8379,
"regions":
{
},
"selection":
[
[
1005,
1005
0,
0
]
],
"settings":
@@ -1323,29 +1332,30 @@
"Python Django": "Python"
},
"sublime_auto_complete": true,
"syntax": "Packages/PHP/PHP.tmLanguage",
"translate_tabs_to_spaces": false
"syntax": "Packages/JavaScript/JavaScript.tmLanguage",
"tab_size": 4,
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
"translation.y": 143.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"type": "text"
},
{
"buffer": 3,
"file": "examples/sprite3.php",
"file": "src/animation/Frame.js",
"settings":
{
"buffer_size": 1406,
"buffer_size": 3046,
"regions":
{
},
"selection":
[
[
1399,
1399
538,
538
]
],
"settings":
@@ -1453,11 +1463,140 @@
"Python Django": "Python"
},
"sublime_auto_complete": true,
"syntax": "Packages/PHP/PHP.tmLanguage",
"syntax": "Packages/JavaScript/JavaScript.tmLanguage",
"translate_tabs_to_spaces": false
},
"translation.x": 0.0,
"translation.y": 285.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"type": "text"
},
{
"buffer": 4,
"file": "src/animation/AnimationManager.js",
"settings":
{
"buffer_size": 6598,
"regions":
{
},
"selection":
[
[
603,
603
]
],
"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": 0.0,
"zoom_level": 1.0
},
"type": "text"
+2
View File
@@ -44,6 +44,8 @@
game.debug.renderPoint(mummy.topRight, 'rgb(0,255,0)');
game.debug.renderPoint(mummy.bottomLeft, 'rgb(0,0,255)');
game.debug.renderPoint(mummy.bottomRight, 'rgb(255,0,255)');
game.debug.renderPoint(mummy.center, 'rgb(255,255,0)');
game.debug.renderRectangle(mummy.bounds, 'rgba(255,255,0,0.1)');
}
+1 -1
View File
@@ -18,7 +18,7 @@ Phaser.AnimationManager = function (parent) {
this._frameData = null;
/**
* Keeps track of the current frame of animation.
* Keeps track of the current frame of the animation.
*/
this.currentFrame = null;
+7
View File
@@ -16,6 +16,7 @@ Phaser.Animation.Frame = function (x, y, width, height, name, uuid) {
this.height = height;
this.name = name;
this.uuid = uuid;
this.distance = Phaser.Math.distance(0, 0, width, height);
};
@@ -50,6 +51,12 @@ Phaser.Animation.Frame.prototype = {
*/
height: 0,
/**
* The distance from the top left to the bottom-right of this Frame.
* @type {number}
*/
distance: 0,
/**
* Useful for Sprite Sheets.
* @type {number}
+11 -1
View File
@@ -108,17 +108,21 @@ Phaser.Sprite = function (game, x, y, key, frame) {
// Edge points
this.offset = new Phaser.Point();
this.center = new Phaser.Point();
this.topLeft = new Phaser.Point();
this.topRight = new Phaser.Point();
this.bottomRight = new Phaser.Point();
this.bottomLeft = new Phaser.Point();
// Do we need all 4 edge points? It might be better to just calculate the center and apply the circle for a bounds check
this.getLocalPosition(this.center, this.offset.x + this.width / 2, this.offset.y + this.height / 2);
this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y);
this.getLocalPosition(this.topRight, this.offset.x + this.width, this.offset.y);
this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this.height);
this.getLocalPosition(this.bottomRight, this.offset.x + this.width, this.offset.y + this.height);
this.bounds = new Phaser.Rectangle(x, y, this.width, this.height);
this._dirty = false;
// transform cache
@@ -200,13 +204,17 @@ Phaser.Sprite.prototype.update = function() {
this.offset.setTo(this._a02 - (this.anchor.x * this._sw), this._a12 - (this.anchor.y * this._sh));
// Do we need all 4 edge points? It might be better to just calculate the center and apply the circle for a bounds check
this.getLocalPosition(this.center, this.offset.x + this.width / 2, this.offset.y + this.height / 2);
this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y);
this.getLocalPosition(this.topRight, this.offset.x + this._sw, this.offset.y);
this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this._sh);
this.getLocalPosition(this.bottomRight, this.offset.x + this._sw, this.offset.y + this._sh);
// Update our bounds
this.getBounds(this.bounds);
}
// this.checkBounds();
// Check our bounds
}
@@ -215,6 +223,8 @@ Phaser.Sprite.prototype.getLocalPosition = function(p, x, y) {
p.x = ((this._a11 * this._id * x + -this._a01 * this._id * y + (this._a12 * this._a01 - this._a02 * this._a11) * this._id) * this._sx) + this._a02;
p.y = ((this._a00 * this._id * y + -this._a10 * this._id * x + (-this._a12 * this._a00 + this._a02 * this._a10) * this._id) * this._sy) + this._a12;
// At this point could be working out the smallest / largest value for the bounds check
return p;
}