• Content Count

  • Joined

  • Last visited

  1. Thanks for all your help. And that i ve solved the problem. this issue due to i create a mew game object throughing extending from Phaser.Game. It turns out that this is unnecessary and can lead to problem. so i correct my code. and the sprite or btn touch events work thanks again.
  2. đŸ˜„resonable! I will have a try. Thank u again.
  3. thanks. but i use phaser-ce. and i have try game.input, it's ok. and in the debug info, i can see the inputInfo, which is listen by the game.input, but cannot see the spriteInputInfo. maybe i should try another pharser version.
  4. i can see the sprite on the screen, but cannot see the log mesage.
  5. thanks you reply very much. here is my 'main.js' import 'pixi' import 'p2' import Phaser from 'phaser' import SplashState from './states/Splash' import GameState from './states/Game' import OverState from './states/Over' // console in mobile chrome import Eruda from 'eruda' Eruda.init() class Game extends Phaser.Game { constructor () { const docElement = document.documentElement const width = docElement.clientWidth const height = docElement.clientHeight super(width * 2, height * 2, Phaser.CANVAS, 'content') // width and height * 2 to solove not clear show in HD screen this.state.add('Splash', SplashState, false) this.state.add('Game', GameState, false) this.state.add('Over', OverState, false) this.state.start('Splash') } } splash state is a transitional picture. then go into Game state. After the game over, it goes into Over state. Part of the Game.js code is below: (for Game.js is large, you can see the whole code at my github: newBlock3.signal.addOnce(() => { console.log('GAME OVER') if (this.gameState) { this.gameState = false this.state.start('Over') Data.score = this.score localStorage.setItem('score', Data.score.toString()) if (this.score > this.hScore) { Data.hScore = this.score localStorage.setItem('hScore', this.hScore.toString()) } } })
  6. thanks. I may not understand what you mean. Do I have other way to handle the click events? Could you tell me ? and here is my github repositories: github repository you can find these code in Over.js. Thanks again.
  7. Thanks for you help. I am just a new learner of Phaser. and I use phaser-ce in my project. I add a sprite to a state, and I want to console something after the sprite is clicked down. what I use is "{console.log('something')},this)", but onInputDown seems to be no work. here is my code: import Phaser from 'phaser' export default class extends Phaser.State { constructor () { super() this.score = 0 this.highestScore = 0 } init () { } preload () { } create () { this.graphic = new Phaser.Graphics(, 0, 0) this.graphic.beginFill(0xffee00) this.graphic.drawRoundedRect(0, 0, 200, 75, 5) this.graphic.endFill() this.textTexture = this.graphic.generateTexture() this.textSprite = this.add.sprite( / 2, / 2 + 100, this.textTexture) this.textSprite.anchor.setTo(0.5) this.text = new Phaser.Text(game, 0, 0, 'Try Again', { font: '40px', fill: '#ee5000', align: 'center' }) this.text.anchor.setTo(0.5) this.textSprite.addChild(this.text3) this.textSprite.inputEnabled = true //I want to click this sprite, but it seems didn't work, try button still cannot work () { console.log('tap dispatched') }, this) } update () { } render () { game.debug.spriteInfo(this.textSprite, 32, 32) game.debug.spriteInputInfo(this.textSprite, 32, 130) } } Here is some of my code, I want to change the state after getting the click signal. And I find the state.input is Ok. I had googled a long time, can't find the reason. Thanks for your help again.