mirror of
https://github.com/wassname/phaser.git
synced 2026-09-10 12:29:30 +08:00
yuidoc scripts added. Tidied up the Docs folder. Added back in the Emitter and fixed the Tests that weren't compiling.
This commit is contained in:
@@ -2,28 +2,34 @@
|
||||
/// <reference path="../../Phaser/ui/Button.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_other_world.png');
|
||||
game.load.atlas('button', 'assets/buttons/button_texture_atlas.png', 'assets/buttons/button_texture_atlas.json');
|
||||
}
|
||||
|
||||
image:
|
||||
Phaser.Sprite
|
||||
Phaser.Sprite;
|
||||
button:
|
||||
Phaser.UI.Button
|
||||
Phaser.UI.Button;
|
||||
|
||||
function create() {
|
||||
// This is just an image that we'll toggle the display of when you click the button
|
||||
this.image = game.add.sprite(game.stage.centerX, 0, 'beast');
|
||||
this.image.transform.origin.setTo(0.5, 0);
|
||||
|
||||
// This button is created from a texture atlas.
|
||||
// Instead of frame IDs (like with a sprite sheet) we can tell it to use frame names instead.
|
||||
// In this case our atlast frame names were called 'over', 'out' and 'down', but they could be anything you want.
|
||||
// The function "clickedIt" will be called when the button is clicked or touched
|
||||
this.button = game.add.button(game.stage.centerX, 400, 'button', clickedIt, this, 'over', 'out', 'down');
|
||||
|
||||
// Just makes the button origin set to the middle, we only do this to center the button on-screen, no other reason
|
||||
this.button.transform.origin.setTo(0.5, 0.5);
|
||||
}
|
||||
|
||||
function clickedIt() {
|
||||
if(this.image.visible == true) {
|
||||
if (this.image.visible == true) {
|
||||
this.image.visible = false;
|
||||
} else {
|
||||
this.image.visible = true;
|
||||
|
||||
@@ -2,29 +2,35 @@
|
||||
/// <reference path="../../Phaser/ui/Button.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png');
|
||||
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
|
||||
}
|
||||
|
||||
image:
|
||||
Phaser.Sprite
|
||||
Phaser.Sprite;
|
||||
button:
|
||||
Phaser.UI.Button
|
||||
Phaser.UI.Button;
|
||||
|
||||
function create() {
|
||||
// This is just an image that we'll toggle the display of when you click the button
|
||||
this.image = game.add.sprite(game.stage.centerX, 0, 'beast');
|
||||
this.image.transform.origin.setTo(0.5, 0);
|
||||
|
||||
// This button is created from a sprite sheet.
|
||||
// Frame 0 = the 'down' state
|
||||
// Frame 1 = the 'out' state
|
||||
// Frame 2 = the 'over' state
|
||||
// The function "clickedIt" will be called when the button is clicked or touched
|
||||
this.button = game.add.button(game.stage.centerX, 400, 'button', clickedIt, this, 2, 1, 0);
|
||||
|
||||
// Just makes the button origin set to the middle, we only do this to center the button on-screen, no other reason
|
||||
this.button.transform.origin.setTo(0.5, 0.5);
|
||||
}
|
||||
|
||||
function clickedIt() {
|
||||
if(this.image.visible == true) {
|
||||
if (this.image.visible == true) {
|
||||
this.image.visible = false;
|
||||
} else {
|
||||
this.image.visible = true;
|
||||
|
||||
@@ -2,25 +2,32 @@
|
||||
/// <reference path="../../Phaser/ui/Button.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
|
||||
}
|
||||
|
||||
var button;
|
||||
var secondCam;
|
||||
|
||||
function create() {
|
||||
button = game.add.button(200, 400, 'button', clickedIt, this, 2, 1, 0);
|
||||
button.origin.setTo(0.5, 0.5);
|
||||
|
||||
game.camera.width = 400;
|
||||
game.camera.texture.opaque = true;
|
||||
game.camera.texture.backgroundColor = 'rgb(100,0,0)';
|
||||
|
||||
secondCam = game.add.camera(400, 0, 400, 600);
|
||||
secondCam.texture.opaque = true;
|
||||
secondCam.texture.backgroundColor = 'rgb(0,100,0)';
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
Phaser.DebugUtils.renderSpriteWorldView(button, 32, 200);
|
||||
}
|
||||
|
||||
function clickedIt() {
|
||||
button.rotation += 10;
|
||||
}
|
||||
|
||||
@@ -2,32 +2,39 @@
|
||||
/// <reference path="../../Phaser/ui/Button.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_other_world.png');
|
||||
game.load.atlas('button', 'assets/buttons/button_texture_atlas.png', 'assets/buttons/button_texture_atlas.json');
|
||||
}
|
||||
|
||||
image:
|
||||
Phaser.Sprite
|
||||
Phaser.Sprite;
|
||||
button:
|
||||
Phaser.UI.Button
|
||||
Phaser.UI.Button;
|
||||
|
||||
function create() {
|
||||
// This is just an image that we'll toggle the display of when you click the button
|
||||
this.image = game.add.sprite(game.stage.centerX, 0, 'beast');
|
||||
this.image.transform.origin.setTo(0.5, 0);
|
||||
|
||||
// This button is created from a texture atlas.
|
||||
// Instead of frame IDs (like with a sprite sheet) we can tell it to use frame names instead.
|
||||
// In this case our atlast frame names were called 'over', 'out' and 'down', but they could be anything you want.
|
||||
// The function "clickedIt" will be called when the button is clicked or touched
|
||||
this.button = game.add.button(game.stage.centerX, 400, 'button', clickedIt, this, 'over', 'out', 'down');
|
||||
|
||||
// Makes the button origin set to the middle
|
||||
this.button.transform.origin.setTo(0.5, 0.5);
|
||||
}
|
||||
|
||||
function update() {
|
||||
// Rotate the button each frame, the button states will still work and respond.
|
||||
this.button.rotation += 1;
|
||||
}
|
||||
|
||||
function clickedIt() {
|
||||
if(this.image.visible == true) {
|
||||
if (this.image.visible == true) {
|
||||
this.image.visible = false;
|
||||
} else {
|
||||
this.image.visible = true;
|
||||
|
||||
Reference in New Issue
Block a user