mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 06:28:30 +00:00
First commi using the new software
This commit is contained in:
parent
574f4f351b
commit
3acdad92cb
20 changed files with 26 additions and 799 deletions
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
$title = "Animation from a Texture Atlas";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create });
|
||||
|
||||
function preload() {
|
||||
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
// This sprite is using a texture atlas for all of its animation data
|
||||
var bot = game.add.sprite(200, 200, 'bot');
|
||||
|
||||
// Here we add a new animation called 'run'
|
||||
// We haven't specified any frames because it's using every frame in the texture atlas
|
||||
bot.animations.add('run');
|
||||
|
||||
// And this starts the animation playing by using its key ("run")
|
||||
// 15 is the frame rate (15fps)
|
||||
// true means it will loop when it finishes
|
||||
bot.animations.play('run', 15, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
Binary file not shown.
Before Width: | Height: | Size: 4.7 KiB |
|
@ -36,7 +36,7 @@
|
|||
function create() {
|
||||
|
||||
//make the world larger than the actual canvas
|
||||
game.world.setBounds(1400,1400);
|
||||
game.world.setBounds(0,0,1400,1400);
|
||||
|
||||
for(var i=0,nb=10;i<nb;i++){
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
game.stage.backgroundColor = '#2d2d2d';
|
||||
|
||||
// Make our game world 2000x2000 pixels in size (the default is to match the game size)
|
||||
game.world.setBounds(2000, 2000);
|
||||
game.world.setBounds(0,0,2000, 2000);
|
||||
|
||||
for (var i = 0; i < 50; i++)
|
||||
{
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
|
||||
<?php
|
||||
$title = "Moving the game camera with the keyboard";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.tilemap('snes', 'assets/maps/smb_tiles.png', 'assets/maps/smb_level1.json', null, Phaser.Tilemap.JSON);
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
|
||||
//setting the size of the game world larger than the tilemap's size
|
||||
game.world.setBounds(2000,2000);
|
||||
|
||||
game.stage.backgroundColor = '#255d3b';
|
||||
|
||||
// adding the tilemap
|
||||
game.add.tilemap(0, 150, 'snes');
|
||||
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
game.camera.x -= 8;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
game.camera.x += 8;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
game.camera.y -= 8;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
game.camera.y += 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
$title = "Adding to group using 'add'";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create,render:render });
|
||||
|
||||
var friendAndFoe,
|
||||
enemies;
|
||||
|
||||
function preload() {
|
||||
game.load.image('ufo', 'assets/sprites/ufo.png');
|
||||
game.load.image('baddie', 'assets/sprites/space-baddie.png');
|
||||
|
||||
}
|
||||
function create() {
|
||||
|
||||
// Create some local groups for later use.
|
||||
friendAndFoe = game.add.group();
|
||||
enemies = game.add.group();
|
||||
|
||||
// Use game.add (GameObjectFactory) to create sprites, those
|
||||
// newly created ones will be added to game.world.group
|
||||
// automatically. While you can still use new to allocate and
|
||||
// only add them to your own groups.
|
||||
var ufo = game.add.sprite(200, 240, 'ufo');
|
||||
friendAndFoe.add(ufo);
|
||||
|
||||
|
||||
// Create some enemies using new keyword.
|
||||
// (Don't forget to pass game as the first parameter.)
|
||||
var enemy;
|
||||
for (var i = 0; i < 16; i++) {
|
||||
|
||||
enemy = new Phaser.Sprite(game,
|
||||
360 + Math.random() * 200, 120 + Math.random() * 200,
|
||||
'baddie');
|
||||
|
||||
enemies.add(enemy);
|
||||
}
|
||||
|
||||
}
|
||||
function render() {
|
||||
|
||||
game.debug.renderText('ufo added to game.world.and "friendAndFoe" group', 20, 24);
|
||||
game.debug.renderText('others ONLY added to "enemies" group', 20, 40);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
<?php
|
||||
$title = "Adding to group using create";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create,render:render });
|
||||
|
||||
function preload() {
|
||||
game.load.image('ufo', 'assets/sprites/ufo.png');
|
||||
game.load.image('baddie', 'assets/sprites/space-baddie.png');
|
||||
|
||||
}
|
||||
|
||||
var friendAndFoe,
|
||||
enemies;
|
||||
|
||||
function create() {
|
||||
// Create some local groups for later use.
|
||||
friendAndFoe = game.add.group();
|
||||
enemies = game.add.group();
|
||||
|
||||
// You can directly create a sprite and add it to a group
|
||||
// using just one line.
|
||||
friendAndFoe.create(200, 240, 'ufo');
|
||||
|
||||
// Create some enemies.
|
||||
for (var i = 0; i < 8; i++) {
|
||||
createBaddie();
|
||||
}
|
||||
|
||||
// Tap to create new baddie sprites.
|
||||
game.input.onTap.add(createBaddie, this);
|
||||
}
|
||||
function createBaddie() {
|
||||
|
||||
enemies.create(360 + Math.random() * 200, 120 + Math.random() * 200,'baddie');
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderText('Tap screen or click to create new baddies.', 16, 24);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
<?php
|
||||
$title = "Bringing to top and game indexes";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<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.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png');
|
||||
game.load.image('snot', 'assets/pics/nslide_snot.png');
|
||||
game.load.image('atari1', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
|
||||
game.load.image('coke', 'assets/sprites/cokecan.png');
|
||||
game.load.image('disk', 'assets/sprites/oz_pov_melting_disk.png');
|
||||
|
||||
|
||||
}
|
||||
|
||||
var group1,
|
||||
group2,
|
||||
coke,
|
||||
disk;
|
||||
|
||||
function create() {
|
||||
|
||||
// Create a background image
|
||||
game.add.sprite(0, 0, 'beast');
|
||||
|
||||
// Create a Group that will sit above the background image
|
||||
group1 = game.add.group();
|
||||
|
||||
// Create a Group that will sit above Group 1
|
||||
group2 = game.add.group();
|
||||
|
||||
// Now let's create some random sprites and enable them all for drag and 'bring to top'
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
|
||||
var tempSprite = game.add.sprite(game.stage.randomX, game.stage.randomY, 'atari1');
|
||||
|
||||
tempSprite.name = 'atari' + i;
|
||||
tempSprite.input.start(i, true);
|
||||
tempSprite.input.enableDrag(false, true);
|
||||
|
||||
group1.add(tempSprite);
|
||||
|
||||
// Sonics
|
||||
|
||||
var tempSprite=game.add.sprite(game.stage.randomX, game.stage.randomY, 'sonic');
|
||||
|
||||
tempSprite.name = 'sonic' + i;
|
||||
tempSprite.input.start(10 + i, true);
|
||||
tempSprite.input.enableDrag(false, true);
|
||||
|
||||
group2.add(tempSprite);
|
||||
}
|
||||
|
||||
// Add 2 control sprites into each group - these cannot be dragged but should be bought to the top each time
|
||||
coke = group1.create(100, 100, 'coke');
|
||||
disk = group2.create(400, 300, 'disk');
|
||||
|
||||
// Create a foreground image - everything should appear behind this, even when dragged
|
||||
var snot = game.add.sprite(game.world.centerX, game.world.height, 'snot');
|
||||
snot.anchor.setTo(0.5, 1);
|
||||
|
||||
// You can click and drag any sprite but Sonic sprites should always appear above the Atari sprites
|
||||
// and both types of sprite should only ever appear above the background and behind the
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (game.input.keyboard.justReleased(Phaser.Keyboard.ONE))
|
||||
{
|
||||
coke.bringToTop();
|
||||
}
|
||||
|
||||
if (game.input.keyboard.justReleased(Phaser.Keyboard.TWO))
|
||||
{
|
||||
disk.bringToTop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
game.debug.renderInputInfo(32, 32);
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
|
||||
<?php
|
||||
$title = "Bring to Top using parent container";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create,render : render });
|
||||
|
||||
var container;
|
||||
|
||||
function preload() {
|
||||
game.load.spritesheet('button', 'assets/buttons/number-buttons.png', 160, 160);
|
||||
|
||||
}
|
||||
function create() {
|
||||
// Container for sorting the buttons, which we'll use to make buttons
|
||||
// to the top later.
|
||||
container = game.add.group();
|
||||
|
||||
// Add buttons to container.
|
||||
container.add(game.add.button(200, 100, 'button', bringMeToTop, this, 0, 0, 0));
|
||||
container.add(game.add.button(300, 100, 'button', bringMeToTop, this, 1, 1, 1));
|
||||
container.add(game.add.button(100, 200, 'button', bringMeToTop, this, 2, 2, 2));
|
||||
container.add(game.add.button(400, 200, 'button', bringMeToTop, this, 3, 3, 3));
|
||||
container.add(game.add.button(300, 300, 'button', bringMeToTop, this, 4, 4, 4));
|
||||
container.add(game.add.button(200, 300, 'button', bringMeToTop, this, 5, 5, 5));
|
||||
}
|
||||
function render() {
|
||||
|
||||
game.debug.renderText('Tap or click buttons to bring it to the top.', 32, 32);
|
||||
}
|
||||
function bringMeToTop(btn) {
|
||||
container.bringToTop(btn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
$title = "Test Title";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('atari1', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('atari2', 'assets/sprites/atari800xl.png');
|
||||
game.load.image('atari4', 'assets/sprites/atari800.png');
|
||||
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
|
||||
game.load.image('duck', 'assets/sprites/darkwing_crazy.png');
|
||||
game.load.image('firstaid', 'assets/sprites/firstaid.png');
|
||||
game.load.image('diamond', 'assets/sprites/diamond.png');
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
// This returns an array of all the image keys in the cache
|
||||
var images = game.cache.getImageKeys();
|
||||
|
||||
// Now let's create some random sprites and enable them all for drag and 'bring to top'
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
var img = game.rnd.pick(images);
|
||||
var tempSprite = game.add.sprite(game.world.randomX, game.world.randomY, img);
|
||||
tempSprite.inputEnabled = true;
|
||||
tempSprite.input.enableDrag(false, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
game.debug.renderInputInfo(32, 32);
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
$title = "Test Title";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('atari1', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('atari2', 'assets/sprites/atari800xl.png');
|
||||
game.load.image('atari4', 'assets/sprites/atari800.png');
|
||||
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
|
||||
game.load.image('duck', 'assets/sprites/darkwing_crazy.png');
|
||||
game.load.image('firstaid', 'assets/sprites/firstaid.png');
|
||||
game.load.image('diamond', 'assets/sprites/diamond.png');
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
// This returns an array of all the image keys in the cache
|
||||
var images = game.cache.getImageKeys();
|
||||
|
||||
var test = game.add.group();
|
||||
|
||||
// Now let's create some random sprites and enable them all for drag and 'bring to top'
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
var tempSprite = test.create(game.world.randomX, game.world.randomY, game.rnd.pick(images));
|
||||
tempSprite.inputEnabled = true;
|
||||
tempSprite.input.enableDrag(false, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
game.debug.renderInputInfo(32, 32);
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
|
@ -8,7 +8,7 @@
|
|||
window.onload = function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render : render });
|
||||
// var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
|
||||
function preload() {
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
if (game.input.mousePointer.isDown)
|
||||
{
|
||||
// 400 is the speed it will move towards the mouse
|
||||
game.physics.moveTowardsMouse(sprite, 400);
|
||||
game.physics.moveToPointer(sprite, 400);
|
||||
|
||||
// if it's overlapping the mouse, don't move any more
|
||||
if (Phaser.Rectangle.contains(sprite.body, game.input.x, game.input.y))
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
$title = "Display a Sprite";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
function preload() {
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
var test = game.add.sprite(200, 200, 'mushroom');
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
$title = "Sprite Sheet and Scale";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }, false, false);
|
||||
|
||||
var timer = 0;
|
||||
var total = 0;
|
||||
|
||||
function preload() {
|
||||
// 37x45 is the size of each frame
|
||||
// There are 18 frames in the PNG - you can leave this value blank if the frames fill up the entire PNG, but in this case there are some
|
||||
// blank frames at the end, so we tell the loader how many to load
|
||||
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
releaseMummy();
|
||||
|
||||
}
|
||||
|
||||
function releaseMummy() {
|
||||
|
||||
var mummy = game.add.sprite(-(Math.random() * 800), game.world.randomY, 'mummy');
|
||||
|
||||
mummy.scale.setTo(2, 2);
|
||||
// If you prefer to work in degrees rather than radians then you can use Phaser.Sprite.angle
|
||||
// otherwise use Phaser.Sprite.rotation
|
||||
mummy.angle = game.rnd.angle();
|
||||
mummy.animations.add('walk');
|
||||
mummy.animations.play('walk', 50, true);
|
||||
|
||||
game.add.tween(mummy).to({ x: game.width + (1600 + mummy.x) }, 20000, Phaser.Easing.Linear.None, true);
|
||||
|
||||
total++;
|
||||
timer = game.time.now + 100;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (total < 200 && game.time.now > timer)
|
||||
{
|
||||
releaseMummy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
$title = "Sprite Animation";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<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.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
|
||||
}
|
||||
|
||||
var s;
|
||||
|
||||
function create() {
|
||||
|
||||
s = game.add.sprite(game.world.centerX, game.world.centerY, 'bot');
|
||||
// s.anchor.setTo(0.5, 0.5);
|
||||
s.scale.setTo(2, 2);
|
||||
|
||||
s.animations.add('run');
|
||||
s.animations.play('run', 10, true);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
s.x -= 4;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
s.x += 4;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
s.y -= 4;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
s.y += 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderSpriteCorners(s, false, false);
|
||||
game.debug.renderSpriteInfo(s, 20, 32);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
$title = "Texture Crop";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
function preload() {
|
||||
game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg');
|
||||
}
|
||||
|
||||
var r;
|
||||
var pic;
|
||||
|
||||
function create() {
|
||||
|
||||
pic = game.add.sprite(game.world.centerX, 550, 'trsi');
|
||||
pic.anchor.setTo(0.5, 1);
|
||||
|
||||
r = new Phaser.Rectangle(0, 0, pic.width, 0);
|
||||
|
||||
game.add.tween(r).to( { height: pic.height }, 3000, Phaser.Easing.Bounce.Out, true, 0, 1000, true);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
// Apply the new crop Rectangle to the sprite
|
||||
pic.crop = r;
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
$title = "Texture Crop";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
function preload() {
|
||||
game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg');
|
||||
}
|
||||
|
||||
var r;
|
||||
var pic;
|
||||
|
||||
function create() {
|
||||
|
||||
pic = game.add.sprite(game.world.centerX, 550, 'trsi');
|
||||
pic.anchor.setTo(0.5, 1);
|
||||
|
||||
r = new Phaser.Rectangle(0, 0, 200, pic.height);
|
||||
|
||||
game.add.tween(r).to( { x: pic.width - 200 }, 3000, Phaser.Easing.Bounce.Out, true, 0, 1000, true);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
// Apply the new crop Rectangle to the sprite
|
||||
pic.crop = r;
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
$title = "Texture Crop";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
function preload() {
|
||||
game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg');
|
||||
}
|
||||
|
||||
var r;
|
||||
var pic;
|
||||
|
||||
function create() {
|
||||
|
||||
pic = game.add.sprite(0, 0, 'trsi');
|
||||
|
||||
r = new Phaser.Rectangle(0, 0, 200, 200);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
r.x = game.input.x;
|
||||
r.y = game.input.y;
|
||||
pic.x = game.input.x;
|
||||
pic.y = game.input.y;
|
||||
|
||||
// Apply the new crop Rectangle to the sprite
|
||||
pic.crop = r;
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
|
@ -10,80 +10,54 @@
|
|||
|
||||
function preload() {
|
||||
|
||||
game.load.tilemap('level3', 'assets/maps/cybernoid.json', null, Phaser.Tilemap.TILED_JSON);
|
||||
game.load.tileset('tiles', 'assets/maps/cybernoid.png', 16, 16);
|
||||
game.load.tilemap('cybernoidLevel3', 'assets/maps/cybernoid.json', null, Phaser.Tilemap.JSON);
|
||||
game.load.tileset('cybernoidTiles', 'assets/maps/cybernoid.png', 16, 16);
|
||||
|
||||
}
|
||||
|
||||
var layer;
|
||||
var cursors;
|
||||
var sprite2;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#3d3d3d';
|
||||
|
||||
var map = new Phaser.Tilemap(game, 'level3');
|
||||
|
||||
// This is a bit nuts, ought to find a way to automate it, but it looks cool :)
|
||||
map.debugMap = [ '#000000',
|
||||
'#e40058', '#e40058', '#e40058', '#80d010', '#bcbcbc', '#e40058', '#000000', '#0070ec', '#bcbcbc', '#bcbcbc', '#bcbcbc',
|
||||
'#bcbcbc', '#bcbcbc', '#e40058', '#e40058', '#0070ec', '#0070ec', '#80d010', '#80d010', '#80d010', '#bcbcbc', '#bcbcbc',
|
||||
'#bcbcbc', '#80d010', '#80d010', '#80d010', '#0070ec', '#0070ec', '#80d010', '#80d010', '#80d010', '#80d010', '#0070ec',
|
||||
'#0070ec', '#24188c', '#24188c', '#80d010', '#80d010', '#80d010', '#bcbcbc', '#80d010', '#80d010', '#80d010', '#e40058',
|
||||
'#e40058', '#bcbcbc', '#e40058', '#bcbcbc', '#e40058', '#bcbcbc', '#80d010', '#bcbcbc', '#80d010', '#000000', '#80d010',
|
||||
'#80d010', '#80d010', '#bcbcbc', '#e40058', '#80d010', '#80d010', '#e40058', '#e40058', '#bcbcbc', '#bcbcbc', '#bcbcbc',
|
||||
'#0070ec', '#0070ec', '#bcbcbc', '#bcbcbc', '#0070ec', '#0070ec', '#bcbcbc', '#bcbcbc', '#bcbcbc', '#bcbcbc', '#bcbcbc',
|
||||
'#bcbcbc', '#bcbcbc'
|
||||
];
|
||||
|
||||
// map.dump();
|
||||
// layer = new Phaser.TilemapLayer(game, 0, 0, 500, 500, [], 'snes');
|
||||
|
||||
// layer = new Phaser.TilemapLayer(game, 0, 0, 640, 400);
|
||||
layer = new Phaser.TilemapLayer(game, 0, 0, 320, 200);
|
||||
layer.updateTileset('tiles');
|
||||
layer.updateMapData(map, 0);
|
||||
// layer = new Phaser.TilemapLayer(game, 0, 0, 500, 500);
|
||||
|
||||
// layer.sprite.anchor.setTo(0.5, 0.5);
|
||||
|
||||
game.world.add(layer.sprite);
|
||||
// layer.load(mapData, tileset);
|
||||
// layer.create(mapWidth, mapHeight, [tileset]);
|
||||
|
||||
// layer.sprite.scale.setTo(2, 2);
|
||||
// layer.updateTileset('cybernoidTiles'); // can change on the fly
|
||||
|
||||
game.add.sprite(320, 0, layer.texture, layer.frame);
|
||||
game.add.sprite(0, 200, layer.texture, layer.frame);
|
||||
game.add.sprite(320, 200, layer.texture, layer.frame);
|
||||
|
||||
cursors = game.input.keyboard.createCursorKeys();
|
||||
// layer.context.fillStyle = 'rgb(255,0,0)';
|
||||
// layer.context.fillRect(0, 0, 200, 300);
|
||||
|
||||
/*
|
||||
game.world._container.addChild(layer.sprite);
|
||||
|
||||
layer.create(10, 10);
|
||||
|
||||
layer.putTile(0, 0, 3);
|
||||
layer.putTile(0, 1, 4);
|
||||
|
||||
layer.render();
|
||||
|
||||
layer.dump();
|
||||
*/
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
// layer.sprite.angle += 0.5;
|
||||
|
||||
if (cursors.up.isDown)
|
||||
{
|
||||
layer.y -= 4;
|
||||
}
|
||||
else if (cursors.down.isDown)
|
||||
{
|
||||
layer.y += 4;
|
||||
}
|
||||
|
||||
if (cursors.left.isDown)
|
||||
{
|
||||
layer.x -= 4;
|
||||
}
|
||||
else if (cursors.right.isDown)
|
||||
{
|
||||
layer.x += 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
layer.render();
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue