mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Commit before refactoring Sprite guts.
This commit is contained in:
parent
03054c1949
commit
1f28d328a7
11 changed files with 1048 additions and 291 deletions
|
@ -150,6 +150,7 @@ Version 1.1
|
|||
* Change: Sprite.crop needs to be enabled with sprite.cropEnabled = true.
|
||||
* Added Rectangle.floorAll to floor all values in a Rectangle (x, y, width and height).
|
||||
* Fixed Sound.resume so it now correctly resumes playback from the point it was paused (fixes issue 51, thanks Yora).
|
||||
* Sprite.loadTexture now works correctly with static images, RenderTextures and Animations.
|
||||
|
||||
|
||||
Outstanding Tasks
|
||||
|
|
|
@ -1,192 +1,640 @@
|
|||
{
|
||||
"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": "pause+and+resume.js", "title": "pause and resume" },
|
||||
{ "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": "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" }
|
||||
]
|
||||
"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": "pause+and+resume.js",
|
||||
"title": "pause and resume"
|
||||
},
|
||||
{
|
||||
"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": "button+scale.js",
|
||||
"title": "button scale"
|
||||
},
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
90
examples/buttons/button scale.js
Normal file
90
examples/buttons/button scale.js
Normal file
|
@ -0,0 +1,90 @@
|
|||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
|
||||
|
||||
game.load.image('sky0','assets/skies/space2.png');
|
||||
game.load.image('sky1','assets/skies/cavern1.png');
|
||||
game.load.image('sky2','assets/skies/chrome.png');
|
||||
game.load.image('sky3','assets/skies/fire.png');
|
||||
game.load.image('sky4','assets/skies/fog.png');
|
||||
game.load.image('sky5','assets/skies/sky1.png');
|
||||
game.load.image('sky6','assets/skies/toxic.png');
|
||||
|
||||
}
|
||||
|
||||
var background;
|
||||
var button1;
|
||||
var button2;
|
||||
var button3;
|
||||
var button4;
|
||||
var button5;
|
||||
var button6;
|
||||
|
||||
function create() {
|
||||
|
||||
background = game.add.sprite(0, 0, 'sky0');
|
||||
background.name = 'background';
|
||||
|
||||
// Standard button (also used as our pointer tracker)
|
||||
button1 = game.add.button(100, 100, 'button', changeSky, this, 2, 1, 0);
|
||||
button1.name = 'sky1';
|
||||
button1.anchor.setTo(0.5, 0.5);
|
||||
|
||||
// Rotated button
|
||||
button2 = game.add.button(330, 200, 'button', changeSky, this, 2, 1, 0);
|
||||
button2.name = 'sky2';
|
||||
button2.angle = 24;
|
||||
button2.anchor.setTo(0.5, 0.5);
|
||||
|
||||
// Width scaled button
|
||||
button3 = game.add.button(100, 300, 'button', changeSky, this, 2, 1, 0);
|
||||
button3.name = 'sky3';
|
||||
button3.width = 300;
|
||||
|
||||
// Scaled button
|
||||
button4 = game.add.button(300, 450, 'button', changeSky, this, 2, 1, 0);
|
||||
button4.name = 'sky4';
|
||||
button4.scale.setTo(2, 2);
|
||||
|
||||
// Shrunk button
|
||||
button5 = game.add.button(100, 450, 'button', changeSky, this, 2, 1, 0);
|
||||
button5.name = 'sky5';
|
||||
button5.scale.setTo(0.5, 0.5);
|
||||
|
||||
// Scaled and Rotated button
|
||||
button6 = game.add.button(600, 200, 'button', changeSky, this, 2, 1, 0);
|
||||
button6.name = 'sky6';
|
||||
button6.angle = 24;
|
||||
button6.scale.setTo(0.5, 2);
|
||||
// button6.anchor.setTo(0.5, 0.5);
|
||||
|
||||
// game.world.setBounds(0, 0, 2000, 2000);
|
||||
// works regardless of world angle, parent angle or camera position
|
||||
// game.world.angle = 5;
|
||||
// game.camera.x = 300;
|
||||
|
||||
}
|
||||
|
||||
function changeSky (button) {
|
||||
|
||||
background.loadTexture(button.name);
|
||||
|
||||
}
|
||||
|
||||
function render () {
|
||||
|
||||
game.debug.renderSpriteCorners(button1, false, true);
|
||||
game.debug.renderSpriteCorners(button2, false, true);
|
||||
game.debug.renderSpriteCorners(button3, false, true);
|
||||
game.debug.renderSpriteCorners(button4, false, true);
|
||||
game.debug.renderSpriteCorners(button5, false, true);
|
||||
game.debug.renderSpriteCorners(button6, false, true);
|
||||
|
||||
// game.debug.renderLocalTransformInfo(button3, 32, 132);
|
||||
// game.debug.renderText('ox: ' + button1.offset.x + ' oy: ' + button1.offset.y, 32, 200);
|
||||
game.debug.renderPoint(button6.input._tempPoint);
|
||||
|
||||
}
|
42
examples/wip/button size.js
Normal file
42
examples/wip/button size.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
|
||||
game.load.image('background','assets/misc/starfield.jpg');
|
||||
|
||||
}
|
||||
|
||||
var button;
|
||||
var background;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#182d3b';
|
||||
|
||||
background = game.add.tileSprite(0, 0, 800, 600, 'background');
|
||||
|
||||
button = game.add.button(game.world.centerX - 95, 200, 'button', actionOnClick, this, 2, 1, 0);
|
||||
button.anchor.setTo(0.5, 0.5);
|
||||
|
||||
button.scale.setTo(2, 2);
|
||||
// button.width = 100;
|
||||
// button.height = 300;
|
||||
button.angle = 10;
|
||||
|
||||
}
|
||||
|
||||
function actionOnClick () {
|
||||
|
||||
background.visible =! background.visible;
|
||||
|
||||
}
|
||||
|
||||
function render () {
|
||||
|
||||
game.debug.renderSpriteCorners(button);
|
||||
|
||||
game.debug.renderPoint(button.input._tempPoint);
|
||||
|
||||
}
|
|
@ -13,17 +13,17 @@ function create() {
|
|||
|
||||
ball = game.add.sprite(300, 0, 'ball');
|
||||
|
||||
startBounceTween();
|
||||
TweenLite.to(ball, 10, { y: 400 });
|
||||
}
|
||||
|
||||
function startBounceTween() {
|
||||
|
||||
ball.y = 0;
|
||||
// ball.y = 0;
|
||||
|
||||
var bounce=game.add.tween(ball);
|
||||
// var bounce=game.add.tween(ball);
|
||||
|
||||
bounce.to({ y: game.world.height-ball.height }, 1000 + Math.random() * 3000, Phaser.Easing.Bounce.In);
|
||||
bounce.onComplete.add(startBounceTween, this);
|
||||
bounce.start();
|
||||
// bounce.to({ y: game.world.height-ball.height }, 1000 + Math.random() * 3000, Phaser.Easing.Bounce.In);
|
||||
// bounce.onComplete.add(startBounceTween, this);
|
||||
// bounce.start();
|
||||
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
<meta charset="UTF-8" />
|
||||
<title>phaser</title>
|
||||
<base href="../"></base>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.10.3/TweenMax.min.js"></script>
|
||||
<?php
|
||||
require('../../build/config.php');
|
||||
|
||||
|
|
|
@ -108,6 +108,7 @@ Phaser.Sprite = function (game, x, y, key, frame) {
|
|||
if (key == null || this.game.cache.checkImageKey(key) == false)
|
||||
{
|
||||
key = '__default';
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
PIXI.Sprite.call(this, PIXI.TextureCache[key]);
|
||||
|
@ -199,12 +200,18 @@ Phaser.Sprite = function (game, x, y, key, frame) {
|
|||
// The actual scale values based on the worldTransform
|
||||
scaleX: 1, scaleY: 1,
|
||||
|
||||
// cache scale check
|
||||
realScaleX: 1, realScaleY: 1,
|
||||
|
||||
// The width/height of the image, based on the un-modified frame size multiplied by the final calculated scale size
|
||||
width: this.currentFrame.sourceSizeW, height: this.currentFrame.sourceSizeH,
|
||||
|
||||
// The actual width/height of the image if from a trimmed atlas, multiplied by the final calculated scale size
|
||||
halfWidth: Math.floor(this.currentFrame.sourceSizeW / 2), halfHeight: Math.floor(this.currentFrame.sourceSizeH / 2),
|
||||
|
||||
// The width/height of the image, based on the un-modified frame size multiplied by the final calculated scale size
|
||||
calcWidth: -1, calcHeight: -1,
|
||||
|
||||
// The current frame details
|
||||
frameID: this.currentFrame.uuid, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height,
|
||||
|
||||
|
@ -352,6 +359,8 @@ Phaser.Sprite.prototype.preUpdate = function() {
|
|||
// Re-run the camera visibility check
|
||||
if (this._cache.dirty)
|
||||
{
|
||||
this.updateBounds();
|
||||
|
||||
this._cache.cameraVisible = Phaser.Rectangle.intersects(this.game.world.camera.screenView, this.bounds, 0);
|
||||
|
||||
if (this.autoCull == true)
|
||||
|
@ -380,6 +389,44 @@ Phaser.Sprite.prototype.updateCache = function() {
|
|||
// |b d ty|
|
||||
// |0 0 1|
|
||||
|
||||
|
||||
// this._cache.width = Math.floor(this.currentFrame.sourceSizeW);
|
||||
// this._cache.height = Math.floor(this.currentFrame.sourceSizeH);
|
||||
// this._cache.halfWidth = Math.floor(this._cache.width / 2);
|
||||
// this._cache.halfHeight = Math.floor(this._cache.height / 2);
|
||||
|
||||
|
||||
// this._cache.scaleX = this.scale.x;
|
||||
// this._cache.scaleY = this.scale.y;
|
||||
|
||||
/*
|
||||
if (this.scale.x !== this._cache.realScaleX || this.scale.y !== this._cache.realScaleY)
|
||||
{
|
||||
console.log('rescale', this.name);
|
||||
this._cache.width = this.width;
|
||||
this._cache.height = this.height;
|
||||
this._cache.halfWidth = Math.floor(this._cache.width / 2);
|
||||
this._cache.halfHeight = Math.floor(this._cache.height / 2);
|
||||
this._cache.realScaleX = this.scale.x;
|
||||
this._cache.realScaleY = this.scale.y;
|
||||
this.updateFrame = true;
|
||||
this._cache.dirty = true;
|
||||
}
|
||||
*/
|
||||
|
||||
if (this._cache.calcWidth !== this.width || this._cache.calcHeight !== this.height)
|
||||
{
|
||||
console.log('calc', this.name);
|
||||
this._cache.width = Math.floor(this.currentFrame.sourceSizeW);
|
||||
this._cache.height = Math.floor(this.currentFrame.sourceSizeH);
|
||||
this._cache.halfWidth = Math.floor(this._cache.width / 2);
|
||||
this._cache.halfHeight = Math.floor(this._cache.height / 2);
|
||||
this._cache.frameWidth = this.texture.frame.width;
|
||||
this._cache.frameHeight = this.texture.frame.height;
|
||||
this._cache.frameID = this.currentFrame.uuid;
|
||||
this._cache.dirty = true;
|
||||
}
|
||||
|
||||
if (this.worldTransform[1] != this._cache.i01 || this.worldTransform[3] != this._cache.i10)
|
||||
{
|
||||
this._cache.a00 = this.worldTransform[0]; // scaleX a
|
||||
|
@ -412,23 +459,149 @@ Phaser.Sprite.prototype.updateAnimation = function() {
|
|||
|
||||
if (this.currentFrame && this.currentFrame.uuid != this._cache.frameID)
|
||||
{
|
||||
this._cache.frameWidth = this.texture.frame.width;
|
||||
this._cache.frameHeight = this.texture.frame.height;
|
||||
this._cache.frameID = this.currentFrame.uuid;
|
||||
// console.log('ua frame 1 change', this.name);
|
||||
// this._cache.frameWidth = this.texture.frame.width;
|
||||
// this._cache.frameHeight = this.texture.frame.height;
|
||||
// this._cache.frameID = this.currentFrame.uuid;
|
||||
this._cache.dirty = true;
|
||||
}
|
||||
|
||||
if (this._cache.dirty && this.currentFrame)
|
||||
{
|
||||
this._cache.width = Math.floor(this.currentFrame.sourceSizeW * this._cache.scaleX);
|
||||
this._cache.height = Math.floor(this.currentFrame.sourceSizeH * this._cache.scaleY);
|
||||
this._cache.halfWidth = Math.floor(this._cache.width / 2);
|
||||
this._cache.halfHeight = Math.floor(this._cache.height / 2);
|
||||
console.log('ua frame 2 change', this.name);
|
||||
// this._cache.width = Math.floor(this.currentFrame.sourceSizeW * this._cache.scaleX);
|
||||
// this._cache.height = Math.floor(this.currentFrame.sourceSizeH * this._cache.scaleY);
|
||||
// this._cache.width = this.currentFrame.width;
|
||||
// // this._cache.height = this.currentFrame.height;
|
||||
// this._cache.width = Math.floor(this.currentFrame.sourceSizeW);
|
||||
// this._cache.height = Math.floor(this.currentFrame.sourceSizeH);
|
||||
// this._cache.halfWidth = Math.floor(this._cache.width / 2);
|
||||
// this._cache.halfHeight = Math.floor(this._cache.height / 2);
|
||||
|
||||
this._cache.id = 1 / (this._cache.a00 * this._cache.a11 + this._cache.a01 * -this._cache.a10);
|
||||
this._cache.idi = 1 / (this._cache.a00 * this._cache.a11 + this._cache.i01 * -this._cache.i10);
|
||||
}
|
||||
|
||||
this.updateBounds();
|
||||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Sprite.prototype.updateBounds
|
||||
*/
|
||||
Phaser.Sprite.prototype.updateBounds = function() {
|
||||
|
||||
// Update the edge points
|
||||
console.log('updateBounds', this.name);
|
||||
|
||||
this.offset.setTo(this._cache.a02 - (this.anchor.x * this._cache.width), this._cache.a12 - (this.anchor.y * this._cache.height));
|
||||
|
||||
this.getLocalPosition(this.center, this.offset.x + this._cache.halfWidth, this.offset.y + this._cache.halfHeight);
|
||||
this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y);
|
||||
this.getLocalPosition(this.topRight, this.offset.x + this._cache.width, this.offset.y);
|
||||
this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this._cache.height);
|
||||
this.getLocalPosition(this.bottomRight, this.offset.x + this._cache.width, this.offset.y + this._cache.height);
|
||||
|
||||
this._cache.left = Phaser.Math.min(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x);
|
||||
this._cache.right = Phaser.Math.max(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x);
|
||||
this._cache.top = Phaser.Math.min(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y);
|
||||
this._cache.bottom = Phaser.Math.max(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y);
|
||||
|
||||
this.bounds.setTo(this._cache.left, this._cache.top, this._cache.right - this._cache.left, this._cache.bottom - this._cache.top);
|
||||
|
||||
// This is the coordinate the Sprite was at when the last bounds was created
|
||||
this._cache.boundsX = this._cache.x;
|
||||
this._cache.boundsY = this._cache.y;
|
||||
|
||||
this._cache.calcWidth = this.width;
|
||||
this._cache.calcHeight = this.height;
|
||||
|
||||
this.updateFrame = true;
|
||||
|
||||
if (this.inWorld == false)
|
||||
{
|
||||
// Sprite WAS out of the screen, is it still?
|
||||
this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold);
|
||||
|
||||
if (this.inWorld)
|
||||
{
|
||||
// It's back again, reset the OOB check
|
||||
this._outOfBoundsFired = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Sprite WAS in the screen, has it now left?
|
||||
this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold);
|
||||
|
||||
if (this.inWorld == false)
|
||||
{
|
||||
this.events.onOutOfBounds.dispatch(this);
|
||||
this._outOfBoundsFired = true;
|
||||
|
||||
if (this.outOfBoundsKill)
|
||||
{
|
||||
this.kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Sprite.prototype.updateBounds
|
||||
*/
|
||||
Phaser.Sprite.prototype.DEADupdateBounds = function() {
|
||||
|
||||
// Update the edge points
|
||||
|
||||
this.offset.setTo(this._cache.a02 - (this.anchor.x * this.width), this._cache.a12 - (this.anchor.y * this.height));
|
||||
|
||||
this.getLocalPosition(this.center, this.offset.x + this._cache.halfWidth, this.offset.y + this._cache.halfHeight);
|
||||
this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y);
|
||||
this.getLocalPosition(this.topRight, this.offset.x + this._cache.width, this.offset.y);
|
||||
this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this._cache.height);
|
||||
this.getLocalPosition(this.bottomRight, this.offset.x + this._cache.width, this.offset.y + this._cache.height);
|
||||
|
||||
this._cache.left = Phaser.Math.min(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x);
|
||||
this._cache.right = Phaser.Math.max(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x);
|
||||
this._cache.top = Phaser.Math.min(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y);
|
||||
this._cache.bottom = Phaser.Math.max(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y);
|
||||
|
||||
this.bounds.setTo(this._cache.left, this._cache.top, this._cache.right - this._cache.left, this._cache.bottom - this._cache.top);
|
||||
|
||||
// This is the coordinate the Sprite was at when the last bounds was created
|
||||
this._cache.boundsX = this._cache.x;
|
||||
this._cache.boundsY = this._cache.y;
|
||||
|
||||
if (this.inWorld == false)
|
||||
{
|
||||
// Sprite WAS out of the screen, is it still?
|
||||
this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold);
|
||||
|
||||
if (this.inWorld)
|
||||
{
|
||||
// It's back again, reset the OOB check
|
||||
this._outOfBoundsFired = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Sprite WAS in the screen, has it now left?
|
||||
this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold);
|
||||
|
||||
if (this.inWorld == false)
|
||||
{
|
||||
this.events.onOutOfBounds.dispatch(this);
|
||||
this._outOfBoundsFired = true;
|
||||
|
||||
if (this.outOfBoundsKill)
|
||||
{
|
||||
this.kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -502,18 +675,23 @@ Phaser.Sprite.prototype.loadTexture = function (key, frame) {
|
|||
{
|
||||
this.currentFrame = this.game.cache.getTextureFrame(key.name);
|
||||
}
|
||||
else if (key instanceof PIXI.Texture)
|
||||
{
|
||||
this.currentFrame = frame;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key == null || this.game.cache.checkImageKey(key) == false)
|
||||
if (typeof key === 'undefined' || this.game.cache.checkImageKey(key) === false)
|
||||
{
|
||||
key = '__default';
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
if (this.game.cache.isSpriteSheet(key))
|
||||
{
|
||||
this.animations.loadFrameData(this.game.cache.getFrameData(key));
|
||||
|
||||
if (frame !== null)
|
||||
if (typeof frame !== 'undefined')
|
||||
{
|
||||
if (typeof frame === 'string')
|
||||
{
|
||||
|
@ -528,11 +706,10 @@ Phaser.Sprite.prototype.loadTexture = function (key, frame) {
|
|||
else
|
||||
{
|
||||
this.currentFrame = this.game.cache.getFrame(key);
|
||||
this.setTexture(PIXI.TextureCache[key]);
|
||||
}
|
||||
}
|
||||
|
||||
this.updateAnimation();
|
||||
|
||||
}
|
||||
|
||||
Phaser.Sprite.prototype.deltaAbsX = function () {
|
||||
|
@ -684,64 +861,6 @@ Phaser.Sprite.prototype.reset = function(x, y, health) {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Sprite.prototype.updateBounds
|
||||
*/
|
||||
Phaser.Sprite.prototype.updateBounds = function() {
|
||||
|
||||
// Update the edge points
|
||||
|
||||
this.offset.setTo(this._cache.a02 - (this.anchor.x * this._cache.width), this._cache.a12 - (this.anchor.y * this._cache.height));
|
||||
|
||||
this.getLocalPosition(this.center, this.offset.x + this._cache.halfWidth, this.offset.y + this._cache.halfHeight);
|
||||
this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y);
|
||||
this.getLocalPosition(this.topRight, this.offset.x + this._cache.width, this.offset.y);
|
||||
this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this._cache.height);
|
||||
this.getLocalPosition(this.bottomRight, this.offset.x + this._cache.width, this.offset.y + this._cache.height);
|
||||
|
||||
this._cache.left = Phaser.Math.min(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x);
|
||||
this._cache.right = Phaser.Math.max(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x);
|
||||
this._cache.top = Phaser.Math.min(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y);
|
||||
this._cache.bottom = Phaser.Math.max(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y);
|
||||
|
||||
this.bounds.setTo(this._cache.left, this._cache.top, this._cache.right - this._cache.left, this._cache.bottom - this._cache.top);
|
||||
|
||||
// This is the coordinate the Sprite was at when the last bounds was created
|
||||
this._cache.boundsX = this._cache.x;
|
||||
this._cache.boundsY = this._cache.y;
|
||||
|
||||
if (this.inWorld == false)
|
||||
{
|
||||
// Sprite WAS out of the screen, is it still?
|
||||
this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold);
|
||||
|
||||
if (this.inWorld)
|
||||
{
|
||||
// It's back again, reset the OOB check
|
||||
this._outOfBoundsFired = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Sprite WAS in the screen, has it now left?
|
||||
this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold);
|
||||
|
||||
if (this.inWorld == false)
|
||||
{
|
||||
this.events.onOutOfBounds.dispatch(this);
|
||||
this._outOfBoundsFired = true;
|
||||
|
||||
if (this.outOfBoundsKill)
|
||||
{
|
||||
this.kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
|
@ -753,8 +872,26 @@ Phaser.Sprite.prototype.updateBounds = function() {
|
|||
*/
|
||||
Phaser.Sprite.prototype.getLocalPosition = function(p, x, y) {
|
||||
|
||||
p.x = ((this._cache.a11 * this._cache.id * x + -this._cache.a01 * this._cache.id * y + (this._cache.a12 * this._cache.a01 - this._cache.a02 * this._cache.a11) * this._cache.id) * this._cache.scaleX) + this._cache.a02;
|
||||
p.y = ((this._cache.a00 * this._cache.id * y + -this._cache.a10 * this._cache.id * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.a10) * this._cache.id) * this._cache.scaleY) + this._cache.a12;
|
||||
// p.x = ((this._cache.a11 * this._cache.id * x + -this._cache.a01 * this._cache.id * y + (this._cache.a12 * this._cache.a01 - this._cache.a02 * this._cache.a11) * this._cache.id) * this.scale.x) + this._cache.a02;
|
||||
// p.y = ((this._cache.a00 * this._cache.id * y + -this._cache.a10 * this._cache.id * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.a10) * this._cache.id) * this.scale.y) + this._cache.a12;
|
||||
|
||||
if (this.worldTransform[0] == 1)
|
||||
{
|
||||
p.x = ((this._cache.a11 * this._cache.id * x + -this._cache.a01 * this._cache.id * y + (this._cache.a12 * this._cache.a01 - this._cache.a02 * this._cache.a11) * this._cache.id) * 1) + this._cache.a02;
|
||||
}
|
||||
else
|
||||
{
|
||||
p.x = ((this._cache.a11 * this._cache.id * x + -this._cache.a01 * this._cache.id * y + (this._cache.a12 * this._cache.a01 - this._cache.a02 * this._cache.a11) * this._cache.id) * this.scale.x) + this._cache.a02;
|
||||
}
|
||||
|
||||
if (this.worldTransform[4] == 1)
|
||||
{
|
||||
p.y = ((this._cache.a00 * this._cache.id * y + -this._cache.a10 * this._cache.id * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.a10) * this._cache.id) * 1) + this._cache.a12;
|
||||
}
|
||||
else
|
||||
{
|
||||
p.y = ((this._cache.a00 * this._cache.id * y + -this._cache.a10 * this._cache.id * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.a10) * this._cache.id) * this.scale.y) + this._cache.a12;
|
||||
}
|
||||
|
||||
return p;
|
||||
|
||||
|
@ -774,6 +911,10 @@ Phaser.Sprite.prototype.getLocalUnmodifiedPosition = function(p, x, y) {
|
|||
p.x = this._cache.a11 * this._cache.idi * x + -this._cache.i01 * this._cache.idi * y + (this._cache.a12 * this._cache.i01 - this._cache.a02 * this._cache.a11) * this._cache.idi;
|
||||
p.y = this._cache.a00 * this._cache.idi * y + -this._cache.i10 * this._cache.idi * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.i10) * this._cache.idi;
|
||||
|
||||
// apply anchor
|
||||
p.x += (this.anchor.x * this.width);
|
||||
p.y += (this.anchor.y * this.height);
|
||||
|
||||
return p;
|
||||
|
||||
}
|
||||
|
@ -886,7 +1027,8 @@ Object.defineProperty(Phaser.Sprite.prototype, "inCamera", {
|
|||
});
|
||||
|
||||
/**
|
||||
* The width of the sprite, setting this will actually modify the scale to acheive the value set
|
||||
* The width of the sprite, setting this will actually modify the scale to acheive the value set.
|
||||
* If you wish to crop the Sprite instead see the Sprite.crop value.
|
||||
*
|
||||
* @property width
|
||||
* @type Number
|
||||
|
@ -898,14 +1040,18 @@ Object.defineProperty(Phaser.Sprite.prototype, 'width', {
|
|||
},
|
||||
|
||||
set: function(value) {
|
||||
this.scale.x = value / this.currentFrame.width
|
||||
|
||||
this.scale.x = value / this.currentFrame.width;
|
||||
this._cache.scaleX = value / this.currentFrame.width;
|
||||
this._width = value;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The height of the sprite, setting this will actually modify the scale to acheive the value set
|
||||
* If you wish to crop the Sprite instead see the Sprite.crop value.
|
||||
*
|
||||
* @property height
|
||||
* @type Number
|
||||
|
@ -913,12 +1059,15 @@ Object.defineProperty(Phaser.Sprite.prototype, 'width', {
|
|||
Object.defineProperty(Phaser.Sprite.prototype, 'height', {
|
||||
|
||||
get: function() {
|
||||
return this.scale.y * this.currentFrame.height;
|
||||
return this.scale.y * this.currentFrame.height;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.scale.y = value / this.currentFrame.height
|
||||
|
||||
this.scale.y = value / this.currentFrame.height;
|
||||
this._cache.scaleY = value / this.currentFrame.height;
|
||||
this._height = value;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -519,7 +519,7 @@ Phaser.Rectangle.inflate = function (a, dx, dy) {
|
|||
* @return {Phaser.Rectangle} The Rectangle object.
|
||||
*/
|
||||
Phaser.Rectangle.inflatePoint = function (a, point) {
|
||||
return Phaser.Phaser.Rectangle.inflate(a, point.x, point.y);
|
||||
return Phaser.Rectangle.inflate(a, point.x, point.y);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -558,6 +558,10 @@ Phaser.Rectangle.contains = function (a, x, y) {
|
|||
return (x >= a.x && x <= a.right && y >= a.y && y <= a.bottom);
|
||||
};
|
||||
|
||||
Phaser.Rectangle.containsRaw = function (rx, ry, rw, rh, x, y) {
|
||||
return (x >= rx && x <= (rx + rw) && y >= ry && y <= (ry + rh));
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter.
|
||||
* @method Phaser.Rectangle.containsPoint
|
||||
|
@ -566,7 +570,7 @@ Phaser.Rectangle.contains = function (a, x, y) {
|
|||
* @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
|
||||
*/
|
||||
Phaser.Rectangle.containsPoint = function (a, point) {
|
||||
return Phaser.Phaser.Rectangle.contains(a, point.x, point.y);
|
||||
return Phaser.Rectangle.contains(a, point.x, point.y);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -484,28 +484,49 @@ Phaser.InputHandler.prototype = {
|
|||
{
|
||||
this.sprite.getLocalUnmodifiedPosition(this._tempPoint, pointer.x, pointer.y);
|
||||
|
||||
// Check against bounds first (move these to private vars)
|
||||
var x1 = -(this.sprite.texture.frame.width) * this.sprite.anchor.x;
|
||||
var y1;
|
||||
|
||||
if (this._tempPoint.x > x1 && this._tempPoint.x < x1 + this.sprite.texture.frame.width)
|
||||
// The unmodified position is being offset by the anchor, i.e. into negative space
|
||||
|
||||
// var x = this.sprite.anchor.x * this.sprite.width;
|
||||
// var y = this.sprite.anchor.y * this.sprite.height;
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
|
||||
// check world transform
|
||||
if (this.sprite.worldTransform[3] == 0 && this.sprite.worldTransform[1] == 0)
|
||||
{
|
||||
y1 = -(this.sprite.texture.frame.height) * this.sprite.anchor.y;
|
||||
|
||||
if (this._tempPoint.y > y1 && this._tempPoint.y < y1 + this.sprite.texture.frame.height)
|
||||
// Un-rotated (but potentially scaled)
|
||||
// if (this._tempPoint.x >= 0 && this._tempPoint.x <= this.sprite.width && this._tempPoint.y >= 0 && this._tempPoint.y <= this.sprite.height)
|
||||
if (this._tempPoint.x >= x && this._tempPoint.x <= this.sprite.width && this._tempPoint.y >= y && this._tempPoint.y <= this.sprite.height)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Rotated (and could be scaled too)
|
||||
// if (this._tempPoint.x >= 0 && this._tempPoint.x <= this.sprite.currentFrame.width && this._tempPoint.y >= 0 && this._tempPoint.y <= this.sprite.currentFrame.height)
|
||||
if (this._tempPoint.x >= x && this._tempPoint.x <= this.sprite.currentFrame.width && this._tempPoint.y >= y && this._tempPoint.y <= this.sprite.currentFrame.height)
|
||||
{
|
||||
if (this.pixelPerfect)
|
||||
{
|
||||
return this.checkPixel(this._tempPoint.x, this._tempPoint.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (this.pixelPerfect)
|
||||
// {
|
||||
// return this.checkPixel(this._tempPoint.x, this._tempPoint.y);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
return false;
|
||||
|
||||
},
|
||||
|
|
|
@ -263,7 +263,8 @@ Phaser.Cache.prototype = {
|
|||
addImage: function (key, url, data) {
|
||||
|
||||
this._images[key] = { url: url, data: data, spriteSheet: false };
|
||||
this._images[key].frame = new Phaser.Frame(0, 0, 0, data.width, data.height, '', '');
|
||||
|
||||
this._images[key].frame = new Phaser.Frame(0, 0, 0, data.width, data.height, key, this.game.rnd.uuid());
|
||||
|
||||
PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data);
|
||||
PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);
|
||||
|
|
|
@ -206,7 +206,7 @@ Phaser.Utils.Debug.prototype = {
|
|||
|
||||
if (showBounds)
|
||||
{
|
||||
this.context.strokeStyle = 'rgba(255,0,255,0.5)';
|
||||
this.context.strokeStyle = 'rgba(0,255,0,0.8)';
|
||||
this.context.strokeRect(sprite.bounds.x, sprite.bounds.y, sprite.bounds.width, sprite.bounds.height);
|
||||
this.context.stroke();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue