mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 13:13:43 +00:00
It loops but still problems on the constructor
This commit is contained in:
parent
fc584cf6bc
commit
bb9761aaf4
6 changed files with 71 additions and 13 deletions
|
@ -7,7 +7,7 @@
|
|||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create});
|
||||
|
||||
function preload() {
|
||||
|
||||
|
@ -27,20 +27,15 @@
|
|||
|
||||
|
||||
music = game.add.audio('squit',1,true);
|
||||
music.play();
|
||||
|
||||
music.play('',0,1,true);
|
||||
|
||||
s = game.add.sprite(game.world.centerX, game.world.centerY, 'spyro');
|
||||
s.anchor.setTo(0.5, 0.5);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
//s.rotation += 0.01;
|
||||
}
|
||||
|
||||
function render() {
|
||||
game.debug.renderSoundInfo(music, 20, 32);
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
|
|
44
examples/display/render crisp.php
Normal file
44
examples/display/render crisp.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
$title = "Canvas Smoothing";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('boss', 'assets/misc/boss1.png');
|
||||
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
|
||||
|
||||
}
|
||||
var boss,
|
||||
button;
|
||||
|
||||
function create() {
|
||||
|
||||
// For browsers that support it, this keeps our pixel art looking crisp
|
||||
//Phaser.Canvas.setSmoothingEnabled(game.stage.canvas.context, false);
|
||||
|
||||
boss = game.add.sprite(game.world.centerX, game.world.centerY, 'boss');
|
||||
boss.anchor.setTo(0.5, 0.5);
|
||||
// Zoom in each time we press it
|
||||
button = game.add.button(32, 32, 'button', clickedIt, this, 2, 1, 0);
|
||||
}
|
||||
|
||||
function clickedIt() {
|
||||
boss.scale.x += 0.5;
|
||||
boss.scale.y += 0.5;
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
|
||||
|
||||
* @class Phaser.Camera
|
||||
* @class Stage
|
||||
* @constructor
|
||||
* @param game {Phaser.Game} game reference to the currently running game.
|
||||
* @param width {number} width of the canvas element
|
||||
|
|
|
@ -115,7 +115,7 @@ Phaser.World.prototype = {
|
|||
|
||||
/**
|
||||
* Destroyer of worlds.
|
||||
* @method setSize
|
||||
* @method destroy
|
||||
*/
|
||||
destroy: function () {
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ Phaser.Sound = function (game, key, volume, loop) {
|
|||
this._volume = volume;
|
||||
this.markers = {};
|
||||
|
||||
|
||||
/**
|
||||
* Reference to AudioContext instance.
|
||||
*/
|
||||
|
@ -109,7 +110,7 @@ Phaser.Sound.prototype = {
|
|||
addMarker: function (name, start, stop, volume, loop) {
|
||||
|
||||
volume = volume || 1;
|
||||
loop = loop || false;
|
||||
if (typeof loop == 'undefined') { loop = false; }
|
||||
|
||||
this.markers[name] = {
|
||||
name: name,
|
||||
|
@ -187,7 +188,9 @@ Phaser.Sound.prototype = {
|
|||
|
||||
/**
|
||||
* Play this sound, or a marked section of it.
|
||||
|
||||
* @param marker {string} Assets key of the sound you want to play.
|
||||
* @param position {number} the starting position
|
||||
* @param [volume] {number} volume of the sound you want to play.
|
||||
* @param [loop] {bool} loop when it finished playing? (Default to false)
|
||||
* @return {Sound} The playing sound object.
|
||||
|
@ -200,7 +203,9 @@ Phaser.Sound.prototype = {
|
|||
if (typeof loop == 'undefined') { loop = false; }
|
||||
if (typeof forceRestart == 'undefined') { forceRestart = false; }
|
||||
|
||||
// console.log('play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop);
|
||||
|
||||
|
||||
console.log('play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop);
|
||||
|
||||
if (this.isPlaying == true && forceRestart == false && this.override == false)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
/**
|
||||
* Phaser - SoundManager
|
||||
*
|
||||
* @class SoundManager
|
||||
* @constructor
|
||||
* @param game {Phaser.Game} reference to the current game instance.
|
||||
*/
|
||||
Phaser.SoundManager = function (game) {
|
||||
|
||||
|
@ -225,10 +228,21 @@ Phaser.SoundManager.prototype = {
|
|||
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @method add
|
||||
* @param key {string} Asset key for the sound.
|
||||
* @param volume {number} default value for the volume.
|
||||
* @param loop {bool} Whether or not the sound will loop.
|
||||
*/
|
||||
|
||||
add: function (key, volume, loop) {
|
||||
|
||||
volume = volume || 1;
|
||||
loop = loop || false;
|
||||
if (typeof loop == 'undefined') { loop = false; }
|
||||
|
||||
|
||||
|
||||
var sound = new Phaser.Sound(this.game, key, volume, loop);
|
||||
|
||||
|
|
Loading…
Reference in a new issue