Jump to content

Search the Community

Showing results for tags 'input.onDown.add'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. Newbie programmer here using phaser for one of my uni assignments! I'm building a side-scrolling oldschool Adventure game. Question 1: What is the correct usage of input.poiterOver()? I have multiple sprites defined on a class Level1.ts basically the usage I'm after is you roll over a mouse on the sprite, it displays the sprite name and you roll-off and the name should disappear. It seems like you cannot do this with multiple sprites in the same context? It will work for ONE sprite (the last sprite called in update() but not any others. What gives? I've encapsulated the sprites as follows: -all sprites are created in create() statue = this.game.add.sprite(330, 162, "statue");statue.inputEnabled = true;innkeeper = this.game.add.sprite(1035, 228, "innkeeper");innkeeper.inputEnabled = true;-then their behavior sits in their own method: (its the same for all sprites) npcInkeeper() { //innkeeper. if (innkeeper.input.pointerOver()) { this.onOverNPC(innkeeper, "Innkeeper"); this.game.input.onDown.add(this.dialogInnkeeper, this.npcInkeeper, 1); } else if (!innkeeper.input.pointerOver()) { this.onOutNPC_name(); } switch (counter_innkeeper) { case 1: //blah blah blah more code and finally in the update() method they are called to update by name. So how do you get this to work for multiple sprites? Question 2: "this.game.input.onDown.add" Is this the best method for a one-off call from mouse? Why can it only be used once on one sprite before going inactive? Same code as above.. Essentially after you roll over a sprite to reveal its name I'm using input.onDown.add to call its dialog method to start once you click. It's important I use one-click here because my dialog system is very hacky (ie: it triggers a counter and then a switch/case displays dialog based on the counter timer) I'm sure there's a better way to do this but all of the mouse methods in phaser were driving me nuts (doensn't appear to be any "onclick" method) only methods that spam ondown calls. The problem? You can apparently only use "input.onDown.add" once. It works on one sprite and then appears to go inactive to being triggered again? I've tried to call removeAll and Dispose on it per the Docs, but to no avail. I've also tried giving it a context (refer to code above) (this.npcInkeeper) to each sprite and also tried giving it a execution priority number. So is there anyway to reset the method? I'm definitely open to suggestions to change stuff. As I've said there doesn't appear to be a way to use a traditional JS .onclick method in phaser if not accessing the DOM (I may just not know the correct way to do it though) if anyone knows how to use it in regards to a phaser.sprite I'm all ears.
×
×
  • Create New...