mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
Star Struck game back and working again, plus finished the level design.
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
+35
-57
@@ -9,7 +9,7 @@
|
||||
*
|
||||
* Phaser - http://www.phaser.io
|
||||
*
|
||||
* v1.0.7 - Built at: Tue, 15 Oct 2013 21:10:11 +0100
|
||||
* v1.0.7 - Built at: Wed, 16 Oct 2013 03:37:04 +0100
|
||||
*
|
||||
* By Richard Davey http://www.photonstorm.com @photonstorm
|
||||
*
|
||||
@@ -18722,8 +18722,7 @@ Phaser.Device.prototype = {
|
||||
|
||||
this.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob'];
|
||||
this.fileSystem = !!window['requestFileSystem'];
|
||||
this.webGL = ( function () { try { return !! window.WebGLRenderingContext && !! document.createElement( 'canvas' ).getContext( 'experimental-webgl' ); } catch( e ) { return false; } } )();
|
||||
// this.webGL = !!window['WebGLRenderingContext'];
|
||||
this.webGL = ( function () { try { var canvas = document.createElement( 'canvas' ); return !! window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ); } catch( e ) { return false; } } )();
|
||||
this.worker = !!window['Worker'];
|
||||
|
||||
if ('ontouchstart' in document.documentElement || window.navigator.msPointerEnabled) {
|
||||
@@ -22300,7 +22299,7 @@ Phaser.Rectangle.union = function (a, b, out) {
|
||||
|
||||
if (typeof out === "undefined") { out = new Phaser.Rectangle(); }
|
||||
|
||||
return out.setTo(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.max(a.right, b.right), Math.max(a.bottom, b.bottom));
|
||||
return out.setTo(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.max(a.right, b.right) - Math.min(a.left, b.left), Math.max(a.bottom, b.bottom) - Math.min(a.top, b.top));
|
||||
|
||||
};
|
||||
|
||||
@@ -24201,7 +24200,7 @@ Phaser.AnimationManager.prototype = {
|
||||
// If they didn't set the useNumericIndex then let's at least try and guess it
|
||||
if (typeof useNumericIndex === 'undefined')
|
||||
{
|
||||
if (frames && frames[0] && typeof frames[0] === 'number')
|
||||
if (frames && typeof frames[0] === 'number')
|
||||
{
|
||||
useNumericIndex = true;
|
||||
}
|
||||
@@ -25148,7 +25147,7 @@ Phaser.FrameData.prototype = {
|
||||
*/
|
||||
getFrame: function (index) {
|
||||
|
||||
if (this._frames[index])
|
||||
if (this._frames.length > index)
|
||||
{
|
||||
return this._frames[index];
|
||||
}
|
||||
@@ -29547,8 +29546,7 @@ Phaser.Utils.Debug.prototype = {
|
||||
this.start(0, 0, color);
|
||||
|
||||
this.context.fillStyle = color;
|
||||
// this.context.fillRect(sprite.body.x - sprite.body.deltaX(), sprite.body.y - sprite.body.deltaY(), sprite.body.width, sprite.body.height);
|
||||
this.context.fillRect(sprite.body.x, sprite.body.y, sprite.body.width, sprite.body.height);
|
||||
this.context.fillRect(sprite.body.screenX, sprite.body.screenY, sprite.body.width, sprite.body.height);
|
||||
|
||||
this.stop();
|
||||
|
||||
@@ -30756,28 +30754,7 @@ Phaser.Physics.Arcade.prototype = {
|
||||
*/
|
||||
separateTile: function (body, tile) {
|
||||
|
||||
var separatedX = this.separateTileX(body, tile, true);
|
||||
var separatedY = this.separateTileY(body, tile, true);
|
||||
|
||||
/*
|
||||
if (separatedX)
|
||||
{
|
||||
console.log('x overlap', this._overlap);
|
||||
}
|
||||
|
||||
|
||||
if (separatedY)
|
||||
{
|
||||
console.log('y overlap', this._overlap);
|
||||
}
|
||||
|
||||
if (separatedX || separatedY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
if (separatedX || separatedY)
|
||||
if (this.separateTileX(body, tile, true) || this.separateTileY(body, tile, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -30805,17 +30782,11 @@ Phaser.Physics.Arcade.prototype = {
|
||||
// The hulls overlap, let's process it
|
||||
this._maxOverlap = body.deltaAbsX() + this.OVERLAP_BIAS;
|
||||
|
||||
console.log('sx hulls over');
|
||||
console.log('x', body.hullX.x, 'y', body.hullX.y, 'bottom', body.hullX.y, 'right', body.hullX.right);
|
||||
console.log(tile);
|
||||
|
||||
if (body.deltaX() < 0)
|
||||
{
|
||||
// Moving left
|
||||
this._overlap = tile.right - body.hullX.x;
|
||||
|
||||
console.log('sx left', this._overlap);
|
||||
|
||||
if ((this._overlap > this._maxOverlap) || body.allowCollision.left == false || tile.tile.collideRight == false)
|
||||
{
|
||||
this._overlap = 0;
|
||||
@@ -30830,8 +30801,6 @@ Phaser.Physics.Arcade.prototype = {
|
||||
// Moving right
|
||||
this._overlap = body.hullX.right - tile.x;
|
||||
|
||||
console.log('sx right', this._overlap);
|
||||
|
||||
if ((this._overlap > this._maxOverlap) || body.allowCollision.right == false || tile.tile.collideLeft == false)
|
||||
{
|
||||
this._overlap = 0;
|
||||
@@ -30849,15 +30818,11 @@ Phaser.Physics.Arcade.prototype = {
|
||||
{
|
||||
if (body.deltaX() < 0)
|
||||
{
|
||||
console.log('sx sep left 1', body.x);
|
||||
body.x = body.x + this._overlap;
|
||||
console.log('sx sep left 2', body.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('sx sep right 1', body.x);
|
||||
body.x = body.x - this._overlap;
|
||||
console.log('sx sep right 2', body.x);
|
||||
}
|
||||
|
||||
if (body.bounce.x == 0)
|
||||
@@ -30872,12 +30837,10 @@ Phaser.Physics.Arcade.prototype = {
|
||||
body.updateHulls();
|
||||
}
|
||||
|
||||
console.log('%c ', 'background: #7f7f7f')
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('%c ', 'background: #7f7f7f')
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -31344,6 +31307,8 @@ Phaser.Physics.Arcade.Body = function (sprite) {
|
||||
this.preX = sprite.x;
|
||||
this.preY = sprite.y;
|
||||
this.preRotation = sprite.angle;
|
||||
this.screenX = sprite.x;
|
||||
this.screenY = sprite.y;
|
||||
|
||||
// un-scaled original size
|
||||
this.sourceWidth = sprite.currentFrame.sourceSizeW;
|
||||
@@ -31442,8 +31407,10 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
this.embedded = false;
|
||||
|
||||
this.preX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
|
||||
this.preY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
|
||||
this.screenX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
|
||||
this.screenY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
|
||||
this.preX = (this.sprite.localTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
|
||||
this.preY = (this.sprite.localTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
|
||||
this.preRotation = this.sprite.angle;
|
||||
|
||||
this.x = this.preX;
|
||||
@@ -31567,8 +31534,10 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
this.angularVelocity = 0;
|
||||
this.angularAcceleration = 0;
|
||||
|
||||
this.preX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
|
||||
this.preY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
|
||||
// this.preX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
|
||||
// this.preY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
|
||||
this.preX = (this.sprite.localTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
|
||||
this.preY = (this.sprite.localTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
|
||||
this.preRotation = this.sprite.angle;
|
||||
|
||||
this.x = this.preX;
|
||||
@@ -32651,8 +32620,6 @@ Phaser.Tilemap = function (game, key) {
|
||||
this.layers = [];
|
||||
}
|
||||
|
||||
console.log(this.layers);
|
||||
|
||||
this.currentLayer = 0;
|
||||
|
||||
this.debugMap = [];
|
||||
@@ -32860,6 +32827,7 @@ Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset,
|
||||
* @default
|
||||
*/
|
||||
this.sprite = new Phaser.Sprite(this.game, x, y, this.texture, this.frame);
|
||||
this.sprite.fixedToCamera = true;
|
||||
|
||||
|
||||
/**
|
||||
@@ -32990,6 +32958,19 @@ Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset,
|
||||
|
||||
Phaser.TilemapLayer.prototype = {
|
||||
|
||||
update: function () {
|
||||
|
||||
this.x = this.game.camera.x;
|
||||
this.y = this.game.camera.y;
|
||||
|
||||
},
|
||||
|
||||
resizeWorld: function () {
|
||||
|
||||
this.game.world.setBounds(0, 0, this.widthInPixels, this.heightInPixels);
|
||||
|
||||
},
|
||||
|
||||
updateTileset: function (tileset) {
|
||||
|
||||
if (tileset instanceof Phaser.Tileset)
|
||||
@@ -33007,6 +32988,7 @@ Phaser.TilemapLayer.prototype = {
|
||||
|
||||
this.tileWidth = this.tileset.tileWidth;
|
||||
this.tileHeight = this.tileset.tileHeight;
|
||||
|
||||
this.updateMax();
|
||||
|
||||
},
|
||||
@@ -33150,11 +33132,6 @@ Phaser.TilemapLayer.prototype = {
|
||||
this._tx = this._dx;
|
||||
this._ty = this._dy;
|
||||
|
||||
// First let's just copy over the whole canvas, offset by the scroll difference
|
||||
|
||||
// Then we only need fill in the missing strip/s (could be top/bottom/left/right I guess)
|
||||
// ScrollZone code might be useful here.
|
||||
|
||||
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||
|
||||
for (var y = this._startY; y < this._startY + this._maxY; y++)
|
||||
@@ -33167,7 +33144,8 @@ Phaser.TilemapLayer.prototype = {
|
||||
var tile = this.tileset.tiles[this._column[x]-1];
|
||||
|
||||
// if (this.tileset.checkTileIndex(tile))
|
||||
// {
|
||||
if (tile)
|
||||
{
|
||||
this.context.drawImage(
|
||||
this.tileset.image,
|
||||
tile.x,
|
||||
@@ -33179,7 +33157,7 @@ Phaser.TilemapLayer.prototype = {
|
||||
this.tileWidth,
|
||||
this.tileHeight
|
||||
);
|
||||
// }
|
||||
}
|
||||
|
||||
this._tx += this.tileWidth;
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -39,36 +39,36 @@
|
||||
19,41,0,0,0,42,19,19,19,53,54,53,53,55,53,54,55,57,60,0,59,56,56,56,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,6,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,19,
|
||||
19,43,0,0,0,18,19,19,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,49,0,0,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,19,19,
|
||||
19,26,0,0,0,35,19,19,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,66,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,7,0,0,0,0,0,0,0,0,0,0,0,0,59,53,54,19,
|
||||
37,26,0,0,0,52,56,56,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,19,19,0,0,0,0,0,0,0,0,0,19,
|
||||
19,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,13,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,9,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,0,0,0,0,0,0,0,0,0,19,
|
||||
19,26,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,2,30,30,31,2,6,7,0,0,13,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,59,19,19,19,0,0,0,0,0,0,0,0,19,
|
||||
19,43,0,0,0,0,0,0,0,0,0,0,0,1,20,21,22,23,19,19,19,19,19,19,19,6,3,30,4,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,41,0,49,50,51,0,47,48,0,0,0,1,36,37,38,39,40,19,19,19,19,19,19,19,19,19,19,19,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,19,3,66,67,68,2,64,65,6,2,3,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,57,57,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,19,20,19,19,19,19,19,37,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,19,19,0,0,0,0,19,
|
||||
37,19,19,19,19,19,20,19,19,38,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,57,60,0,0,0,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,0,0,19,19,0,0,0,0,0,19,19,19,19,0,0,0,0,19,
|
||||
19,19,20,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,41,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,19,
|
||||
19,38,19,19,19,19,19,19,19,19,19,19,19,19,57,57,57,57,57,57,57,57,57,57,60,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,19,19,19,19,19,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,19,19,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,19,19,19,19,19,19,19,19,0,0,0,0,0,19,19,0,0,0,0,0,19,
|
||||
19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,19,19,0,0,0,0,19,19,19,19,0,0,0,0,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,0,0,0,0,0,0,0,0,0,0,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,0,19,19,19,19,19,
|
||||
19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,
|
||||
19,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,19,
|
||||
19,19,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,
|
||||
19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,
|
||||
19,19,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,
|
||||
19,19,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,
|
||||
19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,
|
||||
19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,19,19,19,0,19,19,19,19,19,19,19,19,19,19,
|
||||
19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,19,19,19,19,19,19,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,
|
||||
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19
|
||||
37,26,0,0,0,52,56,56,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,
|
||||
19,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,9,0,0,0,0,0,0,0,0,0,18,
|
||||
19,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,13,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,9,0,0,0,0,0,0,0,0,0,0,0,0,18,19,24,0,0,0,0,0,0,0,0,0,35,
|
||||
19,26,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,2,30,30,31,2,6,7,0,0,13,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,59,57,57,58,0,0,0,0,0,0,0,0,25,
|
||||
19,43,0,0,0,0,0,0,0,0,0,0,0,1,20,21,22,23,19,19,19,19,19,19,19,6,3,30,4,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,
|
||||
19,41,0,49,50,51,0,47,48,0,0,0,1,36,37,38,39,40,19,19,19,19,19,19,19,19,19,19,19,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35,
|
||||
19,19,3,66,67,68,2,64,65,6,2,3,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,57,57,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,
|
||||
19,19,20,19,19,19,19,19,37,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,41,0,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,0,0,0,0,0,1,7,0,0,0,0,0,0,0,1,9,0,0,0,0,18,
|
||||
37,19,19,19,19,19,20,19,19,38,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,57,60,0,0,0,0,0,0,0,0,1,4,4,4,30,9,0,0,0,0,0,0,0,52,58,0,0,0,0,0,1,2,19,41,0,0,0,0,35,
|
||||
19,19,20,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,41,0,0,0,0,0,0,0,0,0,0,18,19,19,19,19,19,9,13,0,0,0,0,0,0,0,0,0,0,0,0,52,53,56,58,0,0,0,0,18,
|
||||
19,38,19,19,19,19,56,56,56,19,19,19,19,56,56,56,54,56,56,53,56,56,54,56,60,0,0,0,0,0,0,0,0,1,5,19,19,19,19,19,19,19,9,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,
|
||||
19,19,19,56,56,60,0,0,0,18,19,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,19,19,19,19,19,19,19,19,19,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,
|
||||
19,56,60,0,0,0,0,0,0,35,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,4,19,19,19,19,19,56,56,56,56,56,19,3,4,4,4,5,6,7,0,0,0,0,0,0,0,0,0,0,0,0,18,
|
||||
43,0,0,0,0,0,0,0,0,52,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,4,4,4,19,19,19,19,19,19,60,0,0,0,0,0,35,19,37,38,19,19,19,41,0,0,0,0,0,1,9,0,0,0,0,0,35,
|
||||
60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,1,4,4,4,19,22,23,19,19,19,19,56,56,60,0,0,0,0,0,0,52,55,54,53,54,57,54,58,0,0,0,0,1,19,19,9,0,0,0,0,18,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,4,30,4,4,4,19,19,19,19,19,39,40,19,19,19,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,58,0,0,0,0,1,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,19,19,19,19,19,56,56,53,56,56,56,56,53,56,56,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,56,56,56,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,1,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,9,0,0,0,0,0,0,0,0,0,17,42,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,9,0,0,0,0,0,0,1,19,19,19,9,0,0,0,0,0,0,0,1,34,19,19,19,
|
||||
9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35,19,19,24,0,0,0,0,0,1,19,19,19,19,58,0,0,0,0,0,0,1,19,19,19,19,19,
|
||||
41,0,0,0,0,0,0,0,0,0,0,0,1,2,4,4,5,5,6,5,2,4,5,6,4,2,6,4,7,0,0,0,0,0,0,1,5,19,19,19,41,0,0,0,0,0,52,56,56,56,58,0,0,0,0,0,0,1,19,19,19,19,21,36,
|
||||
19,9,0,0,0,0,0,0,0,0,0,0,52,57,53,53,19,19,19,19,19,19,19,19,19,19,19,19,24,0,0,0,0,0,0,52,19,19,19,19,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,19,19,19,36,38,19,
|
||||
19,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,57,19,19,19,19,19,19,19,19,19,19,19,5,9,0,0,0,0,0,35,19,19,19,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,19,19,19,19,19,19,19,
|
||||
19,41,0,0,0,0,0,1,9,0,0,0,0,0,0,0,0,0,35,19,19,19,19,19,54,53,53,54,55,55,58,0,0,0,0,0,52,56,56,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,19,21,19,19,20,37,19,
|
||||
19,26,0,0,0,0,0,52,58,0,0,0,0,0,0,0,0,0,18,19,54,53,53,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,19,19,20,19,19,38,19,19,
|
||||
19,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,47,48,0,0,35,19,19,20,36,19,19,20,19,
|
||||
19,19,5,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35,43,0,0,0,0,0,0,0,0,0,0,0,0,0,17,0,0,0,0,0,0,0,0,0,1,5,6,7,0,0,0,1,64,7,0,1,19,19,37,22,23,37,19,19,22,
|
||||
19,19,19,41,0,0,0,47,48,0,47,48,0,47,48,0,1,5,19,43,0,13,14,14,13,14,14,0,0,0,0,1,5,34,9,0,0,49,49,50,0,0,1,19,19,19,19,9,0,1,19,19,19,6,19,19,38,19,39,40,19,19,19,39,
|
||||
19,19,19,19,5,5,5,64,65,5,64,65,5,64,65,5,19,19,19,19,2,30,31,31,30,31,31,5,2,3,2,21,22,23,19,5,5,66,66,67,5,5,19,19,19,19,19,19,6,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
||||
|
||||
@@ -5,13 +5,12 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
// game.load.tilemap('level1', 'assets/games/starstruck/tiles-1.png', 'assets/games/starstruck/level1.json', null, Phaser.Tilemap.JSON);
|
||||
game.load.tilemap('level1', 'assets/games/starstruck/level1.json', null, Phaser.Tilemap.TILED_JSON);
|
||||
game.load.tileset('tiles', 'assets/games/starstruck/tiles-1.png', 16, 16);
|
||||
game.load.spritesheet('dude', 'assets/games/starstruck/dude.png', 32, 48);
|
||||
game.load.spritesheet('droid', 'assets/games/starstruck/droid.png', 32, 32);
|
||||
game.load.image('starSmall', 'assets/games/starstruck/star.png');
|
||||
@@ -21,6 +20,8 @@
|
||||
}
|
||||
|
||||
var map;
|
||||
var tileset;
|
||||
var layer;
|
||||
var player;
|
||||
var facing = 'left';
|
||||
var jumpTimer = 0;
|
||||
@@ -33,16 +34,25 @@
|
||||
bg = game.add.tileSprite(0, 0, 800, 600, 'background');
|
||||
bg.fixedToCamera = true;
|
||||
|
||||
map = game.add.tilemap(0, 0, 'level1');
|
||||
map.setCollisionRange(1, 12, true, true, true, true);
|
||||
map.setCollisionRange(18, 47, true, true, true, true);
|
||||
map.setCollisionRange(53, 69, true, true, true, true);
|
||||
map = new Phaser.Tilemap(game, 'level1');
|
||||
|
||||
// player = game.add.sprite(32, 32, 'dude');
|
||||
player = game.add.sprite(250, 220, 'dude');
|
||||
tileset = game.cache.getTileset('tiles');
|
||||
|
||||
tileset.setCollisionRange(0, tileset.total - 1, true, true, true, true);
|
||||
|
||||
tileset.setCollisionRange(12, 17, false, false, false, false);
|
||||
tileset.setCollisionRange(46, 51, false, false, false, false);
|
||||
|
||||
layer = new Phaser.TilemapLayer(game, 0, 0, 800, 600, tileset, map, 0);
|
||||
layer.resizeWorld();
|
||||
|
||||
game.world.add(layer.sprite);
|
||||
|
||||
player = game.add.sprite(32, 32, 'dude');
|
||||
player.body.bounce.y = 0.2;
|
||||
player.body.collideWorldBounds = true;
|
||||
// player.body.gravity.y = 10;
|
||||
player.body.gravity.y = 6;
|
||||
player.body.setSize(16, 32, 8, 16);
|
||||
|
||||
player.animations.add('left', [0, 1, 2, 3], 10, true);
|
||||
player.animations.add('turn', [4], 20, true);
|
||||
@@ -54,10 +64,23 @@
|
||||
|
||||
function update() {
|
||||
|
||||
game.physics.collide(player, map);
|
||||
layer.update();
|
||||
|
||||
// getTiles: function (x, y, width, height, collides, layer) {
|
||||
overlap = layer.getTiles(player.body.x, player.body.y, player.body.width, player.body.height, true);
|
||||
|
||||
if (overlap.length > 1)
|
||||
{
|
||||
for (var i = 1; i < overlap.length; i++)
|
||||
{
|
||||
game.physics.separateTile(player.body, overlap[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// game.physics.collide(player, map);
|
||||
|
||||
player.body.velocity.x = 0;
|
||||
player.body.velocity.y = 0;
|
||||
// player.body.velocity.y = 0;
|
||||
// player.body.acceleration.y = 500;
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
@@ -98,37 +121,29 @@
|
||||
facing = 'idle';
|
||||
}
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
player.body.velocity.y = -150;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
player.body.velocity.y = 150;
|
||||
}
|
||||
|
||||
|
||||
// if (game.input.keyboard.isDown(Phaser.Keyboard.UP) || game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
|
||||
// {
|
||||
// if (player.body.touching.down && game.time.now > jumpTimer)
|
||||
// {
|
||||
// player.body.velocity.y = -200;
|
||||
// jumpTimer = game.time.now + 500;
|
||||
// }
|
||||
// }
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP) || game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
|
||||
{
|
||||
if (player.body.touching.down && game.time.now > jumpTimer)
|
||||
{
|
||||
player.body.velocity.y = -250;
|
||||
jumpTimer = game.time.now + 750;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderSpriteInfo(player, 32, 32);
|
||||
game.debug.renderSpriteCorners(player, false, true);
|
||||
game.debug.renderSpriteCollision(player, 32, 320);
|
||||
layer.render();
|
||||
|
||||
// game.debug.renderSpriteBody(player);
|
||||
|
||||
// game.debug.renderSpriteInfo(player, 32, 32);
|
||||
// game.debug.renderSpriteCollision(player, 32, 320);
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
@@ -635,28 +635,7 @@ Phaser.Physics.Arcade.prototype = {
|
||||
*/
|
||||
separateTile: function (body, tile) {
|
||||
|
||||
var separatedX = this.separateTileX(body, tile, true);
|
||||
var separatedY = this.separateTileY(body, tile, true);
|
||||
|
||||
/*
|
||||
if (separatedX)
|
||||
{
|
||||
console.log('x overlap', this._overlap);
|
||||
}
|
||||
|
||||
|
||||
if (separatedY)
|
||||
{
|
||||
console.log('y overlap', this._overlap);
|
||||
}
|
||||
|
||||
if (separatedX || separatedY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
if (separatedX || separatedY)
|
||||
if (this.separateTileX(body, tile, true) || this.separateTileY(body, tile, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -684,17 +663,11 @@ Phaser.Physics.Arcade.prototype = {
|
||||
// The hulls overlap, let's process it
|
||||
this._maxOverlap = body.deltaAbsX() + this.OVERLAP_BIAS;
|
||||
|
||||
console.log('sx hulls over');
|
||||
console.log('x', body.hullX.x, 'y', body.hullX.y, 'bottom', body.hullX.y, 'right', body.hullX.right);
|
||||
console.log(tile);
|
||||
|
||||
if (body.deltaX() < 0)
|
||||
{
|
||||
// Moving left
|
||||
this._overlap = tile.right - body.hullX.x;
|
||||
|
||||
console.log('sx left', this._overlap);
|
||||
|
||||
if ((this._overlap > this._maxOverlap) || body.allowCollision.left == false || tile.tile.collideRight == false)
|
||||
{
|
||||
this._overlap = 0;
|
||||
@@ -709,8 +682,6 @@ Phaser.Physics.Arcade.prototype = {
|
||||
// Moving right
|
||||
this._overlap = body.hullX.right - tile.x;
|
||||
|
||||
console.log('sx right', this._overlap);
|
||||
|
||||
if ((this._overlap > this._maxOverlap) || body.allowCollision.right == false || tile.tile.collideLeft == false)
|
||||
{
|
||||
this._overlap = 0;
|
||||
@@ -728,15 +699,11 @@ Phaser.Physics.Arcade.prototype = {
|
||||
{
|
||||
if (body.deltaX() < 0)
|
||||
{
|
||||
console.log('sx sep left 1', body.x);
|
||||
body.x = body.x + this._overlap;
|
||||
console.log('sx sep left 2', body.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('sx sep right 1', body.x);
|
||||
body.x = body.x - this._overlap;
|
||||
console.log('sx sep right 2', body.x);
|
||||
}
|
||||
|
||||
if (body.bounce.x == 0)
|
||||
@@ -751,12 +718,10 @@ Phaser.Physics.Arcade.prototype = {
|
||||
body.updateHulls();
|
||||
}
|
||||
|
||||
console.log('%c ', 'background: #7f7f7f')
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('%c ', 'background: #7f7f7f')
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@ Phaser.Tilemap = function (game, key) {
|
||||
this.layers = [];
|
||||
}
|
||||
|
||||
console.log(this.layers);
|
||||
|
||||
this.currentLayer = 0;
|
||||
|
||||
this.debugMap = [];
|
||||
|
||||
@@ -179,8 +179,6 @@ Phaser.TilemapLayer.prototype = {
|
||||
|
||||
this.game.world.setBounds(0, 0, this.widthInPixels, this.heightInPixels);
|
||||
|
||||
console.log('world', this.game.world.bounds);
|
||||
|
||||
},
|
||||
|
||||
updateTileset: function (tileset) {
|
||||
@@ -200,6 +198,7 @@ Phaser.TilemapLayer.prototype = {
|
||||
|
||||
this.tileWidth = this.tileset.tileWidth;
|
||||
this.tileHeight = this.tileset.tileHeight;
|
||||
|
||||
this.updateMax();
|
||||
|
||||
},
|
||||
@@ -355,7 +354,8 @@ Phaser.TilemapLayer.prototype = {
|
||||
var tile = this.tileset.tiles[this._column[x]-1];
|
||||
|
||||
// if (this.tileset.checkTileIndex(tile))
|
||||
// {
|
||||
if (tile)
|
||||
{
|
||||
this.context.drawImage(
|
||||
this.tileset.image,
|
||||
tile.x,
|
||||
@@ -367,7 +367,7 @@ Phaser.TilemapLayer.prototype = {
|
||||
this.tileWidth,
|
||||
this.tileHeight
|
||||
);
|
||||
// }
|
||||
}
|
||||
|
||||
this._tx += this.tileWidth;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user