mirror of
https://github.com/wassname/phaser.git
synced 2026-07-17 01:30:32 +08:00
Fixed issue in Camera.inCamera check where it wouldn't take into consideration the Sprites scrollFactor.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
|
||||
function init() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('sprite', 'assets/sprites/darkwing_crazy.png');
|
||||
game.loader.load();
|
||||
}
|
||||
var sprite;
|
||||
function create() {
|
||||
game.stage.backgroundColor = 'rgb(85,85,85)';
|
||||
sprite = game.add.sprite(200, 200, 'sprite');
|
||||
// Enable Input detection. Sprites have this disabled by default,
|
||||
// so you have to start it if you want to interact with them.
|
||||
sprite.input.start(0, false, true);
|
||||
// This allows you to drag the sprite. The parameter controls if you drag from the position you touched it (false)
|
||||
// or if it will snap to the center (true)
|
||||
sprite.input.enableDrag();
|
||||
// This will lock the sprite so it can only be dragged vertically, not horizontally
|
||||
sprite.input.allowHorizontalDrag = false;
|
||||
}
|
||||
function render() {
|
||||
game.input.renderDebugInfo(32, 32);
|
||||
sprite.input.renderDebugInfo(300, 32);
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,43 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
|
||||
|
||||
function init() {
|
||||
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('sprite', 'assets/sprites/darkwing_crazy.png');
|
||||
game.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var sprite: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = 'rgb(85,85,85)';
|
||||
|
||||
sprite = game.add.sprite(200, 200, 'sprite');
|
||||
|
||||
// Enable Input detection. Sprites have this disabled by default,
|
||||
// so you have to start it if you want to interact with them.
|
||||
sprite.input.start(0, false, true);
|
||||
|
||||
// This allows you to drag the sprite. The parameter controls if you drag from the position you touched it (false)
|
||||
// or if it will snap to the center (true)
|
||||
sprite.input.enableDrag();
|
||||
|
||||
// This will lock the sprite so it can only be dragged vertically, not horizontally
|
||||
sprite.input.allowHorizontalDrag = false;
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.input.renderDebugInfo(32, 32);
|
||||
sprite.input.renderDebugInfo(300, 32);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,26 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
|
||||
function init() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('sprite', 'assets/sprites/parsec.png');
|
||||
game.loader.load();
|
||||
}
|
||||
var sprite;
|
||||
function create() {
|
||||
game.stage.backgroundColor = 'rgb(85,85,85)';
|
||||
sprite = game.add.sprite(200, 400, 'sprite');
|
||||
// Enable Input detection. Sprites have this disabled by default,
|
||||
// so you have to start it if you want to interact with them.
|
||||
sprite.input.start(0, false, true);
|
||||
// This allows you to drag the sprite. The parameter controls if you drag from the position you touched it (false)
|
||||
// or if it will snap to the center (true)
|
||||
sprite.input.enableDrag();
|
||||
// This will lock the sprite so it can only be dragged horizontally, not vertically
|
||||
sprite.input.allowVerticalDrag = false;
|
||||
}
|
||||
function render() {
|
||||
game.input.renderDebugInfo(32, 32);
|
||||
sprite.input.renderDebugInfo(300, 32);
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,43 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
|
||||
|
||||
function init() {
|
||||
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('sprite', 'assets/sprites/parsec.png');
|
||||
game.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var sprite: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = 'rgb(85,85,85)';
|
||||
|
||||
sprite = game.add.sprite(200, 400, 'sprite');
|
||||
|
||||
// Enable Input detection. Sprites have this disabled by default,
|
||||
// so you have to start it if you want to interact with them.
|
||||
sprite.input.start(0, false, true);
|
||||
|
||||
// This allows you to drag the sprite. The parameter controls if you drag from the position you touched it (false)
|
||||
// or if it will snap to the center (true)
|
||||
sprite.input.enableDrag();
|
||||
|
||||
// This will lock the sprite so it can only be dragged horizontally, not vertically
|
||||
sprite.input.allowVerticalDrag = false;
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.input.renderDebugInfo(32, 32);
|
||||
sprite.input.renderDebugInfo(300, 32);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,33 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
|
||||
function init() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
game.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
|
||||
game.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png');
|
||||
game.loader.load();
|
||||
}
|
||||
var atari1;
|
||||
var atari2;
|
||||
var sonic;
|
||||
function create() {
|
||||
game.add.sprite(0, 0, 'grid');
|
||||
atari1 = game.add.sprite(128, 128, 'atari1');
|
||||
atari2 = game.add.sprite(256, 256, 'atari2');
|
||||
// Input Enable the sprites
|
||||
atari1.input.start(0, false, true);
|
||||
atari2.input.start(1, false, true);
|
||||
// Allow dragging
|
||||
atari1.input.enableDrag();
|
||||
atari2.input.enableDrag();
|
||||
// Enable snapping. For the atari1 sprite it will snap as its dragged around and on release.
|
||||
// The snap is set to every 32x32 pixels.
|
||||
atari1.input.enableSnap(32, 32, true, true);
|
||||
// For the atari2 sprite it will snap only when released, not on drag.
|
||||
atari2.input.enableSnap(32, 32, false, true);
|
||||
}
|
||||
function render() {
|
||||
game.input.renderDebugInfo(32, 32);
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,49 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
|
||||
|
||||
function init() {
|
||||
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
game.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
|
||||
game.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png');
|
||||
game.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var atari1: Phaser.Sprite;
|
||||
var atari2: Phaser.Sprite;
|
||||
var sonic: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
game.add.sprite(0, 0, 'grid');
|
||||
|
||||
atari1 = game.add.sprite(128, 128, 'atari1');
|
||||
atari2 = game.add.sprite(256, 256, 'atari2');
|
||||
|
||||
// Input Enable the sprites
|
||||
atari1.input.start(0, false, true);
|
||||
atari2.input.start(1, false, true);
|
||||
|
||||
// Allow dragging
|
||||
atari1.input.enableDrag();
|
||||
atari2.input.enableDrag();
|
||||
|
||||
// Enable snapping. For the atari1 sprite it will snap as its dragged around and on release.
|
||||
// The snap is set to every 32x32 pixels.
|
||||
atari1.input.enableSnap(32, 32, true, true);
|
||||
|
||||
// For the atari2 sprite it will snap only when released, not on drag.
|
||||
atari2.input.enableSnap(32, 32, false, true);
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
game.input.renderDebugInfo(32, 32);
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,36 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
|
||||
function init() {
|
||||
game.world.setSize(1920, 1200, true);
|
||||
game.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg');
|
||||
game.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
game.loader.load();
|
||||
}
|
||||
function create() {
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
for(var i = 0; i < 1; i++) {
|
||||
//var sprite: Phaser.Sprite = game.add.sprite(game.world.randomX, game.world.randomY, 'melon');
|
||||
var sprite = game.add.sprite(200, 200, 'melon');
|
||||
sprite.scrollFactor.setTo(2, 2);
|
||||
sprite.scale.setTo(2, 2);
|
||||
sprite.input.start(i, false, true);
|
||||
sprite.input.enableDrag();
|
||||
}
|
||||
}
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.scroll.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.scroll.x += 4;
|
||||
}
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
game.camera.scroll.y -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
game.camera.scroll.y += 4;
|
||||
}
|
||||
}
|
||||
function render() {
|
||||
game.camera.renderDebugInfo(32, 32);
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,59 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
|
||||
|
||||
function init() {
|
||||
|
||||
game.world.setSize(1920, 1200, true);
|
||||
|
||||
game.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg');
|
||||
game.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
|
||||
game.loader.load();
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
|
||||
for (var i = 0; i < 1; i++)
|
||||
{
|
||||
var sprite: Phaser.Sprite = game.add.sprite(game.world.randomX, game.world.randomY, 'melon');
|
||||
sprite.input.start(i, false, true);
|
||||
sprite.input.enableDrag();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
game.camera.scroll.x -= 4;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
game.camera.scroll.x += 4;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
game.camera.scroll.y -= 4;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
game.camera.scroll.y += 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.camera.renderDebugInfo(32, 32);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user