mirror of
https://github.com/wassname/phaser.git
synced 2026-09-10 12:29:30 +08:00
Commit before refactoring Sprite guts.
This commit is contained in:
@@ -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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user