Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var config = {
- type: Phaser.AUTO,
- backgroundColor: '#363742',
- scale:{
- mode: Phaser.Scale.FIT,
- autoCenter: Phaser.Scale.CENTER_BOTH,
- width: 800,
- height: 600,
- },
- parent: 'phaser-example',
- scene: {
- create: create,
- update: update,
- physics: {
- matter: {
- debug: false,
- gravity: { y:0, x:0 }//1.8 for 10ft .433 for 5m
- }
- }
- }
- };
- var game = new Phaser.Game(config);
- var timedEvent;
- var output;
- function create ()
- {
- timedEvent = this.time.addEvent({ delay: 1, callback: timeR, callbackScope: this, loop: true,paused:true});
- this.add.text(300, 300, "START").setInteractive().on('pointerdown',function(pointer){start();},this);;
- this.add.text(400, 300, "RESET").setInteractive().on('pointerdown',function(pointer){reset(this);},this);;
- output = this.add.text(350, 250, "0.000");
- }
- function update()
- {
- timeout = (timedEvent.getProgress()/1000).toFixed(3);
- output.setText(timeout);
- }
- function timeR(){}
- function start(){
- if(timedEvent.paused){
- timedEvent.paused = false;
- console.log('unpaused')}
- else{
- timedEvent.paused=true;
- console.log('paused')
- }
- }
- function reset(scope){
- timedEvent.reset();
- timedEvent = scope.time.addEvent({ delay: 1, callback: timeR, callbackScope: this, loop: true, paused:true});
- }
Add Comment
Please, Sign In to add comment