Search the Community

Showing results for tags 'onInputDown'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

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 11 results

  1. 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 "sprite.events.onInputDown.add(function(){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(this.game, 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(this.game.width / 2, this.game.height / 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 this.textSprite.events.onInputDown.add(function () { 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.
  2. I'm trying to make a menu like option to where the user can drag a sprite on screen and make a clone out of it leaving the other sprite on it's original location. This is what I have up untill now. var box = game.add.sprite(100, 200, 'box', 0); box.anchor.set(0); box.inputEnabled = true; box.events.onInputDown.add(clone, this, 0, box); function clone(obj){ var clone = game.add.sprite(obj.x, obj.y, obj.key, obj.frame); clone.inputEnabled = true; clone.input.enableDrag(true); } Only down side is I have to click twice on the sprite in order for there to be a copy of it which kind of takes away the whole purpose of a copy on drag function. Any help would be greatly appreciated. (I'm quite new to Phaser and js so I'm sorry for any obvious mistakes beforehand) Thanks in advance!
  3. Hi all ! Today, i upload game to Appstore then rejected. Game dont run. I Checked and see that : Event "onInputDown" dont run on Webview IOS 10.3 Code: this.btHome = this.add.sprite(Candy.GAME_WIDTH / 2, ((this.logo.y) + 330), 'homeindex'); this.btHome.anchor.setTo(0.5, 0.5); this.btHome.inputEnabled = true; this.btHome.input.useHandCursor = true; this.btHome.events.onInputDown.add(function () { game.state.states['HomeIndex'].EnterGame(); }, this); How fix this ? Thank for supporting
  4. Hi all, I'm having a problem with input events on my sprites. I have a grid of tiles, with an added child sprite. I've added an onInputDown event handler onto each tile. All works well, mostly... but then after a few clicks it seems that the sprite passed to my handler doesn't change - it remains the last sprite clicked. Here's some code: var pos = { x: 0, y: 0 }; var cols = 10; var rows = 10; var numberOfTiles = cols * rows; var tileWidth = 65; var tileHeight = 65; // Place tiles for (var i = 1; i <= numberOfTiles; i++) { var thisTile = this.game.add.sprite(pos.x, pos.y, 'tile', 1); var thisSprite = thisTile.addChild(this.game.make.sprite(0,0, 'tile', 4)); thisTile.inputEnabled = true; thisTile.events.onInputDown.add(this.onDown, this); pos.x += tileWidth; // New column if (i % cols === 0) { pos.y += tileHeight; pos.x = 0; } } This sets out the tiles with no problems. Frame 1 for my background and frame 4 for the foreground. In my onDown function I tween the child sprite down to scale: 0 and alpha: 0. I also do a bit of calculation to work out which tile is clicked. onDown: function(sprite) { var thisRow = (sprite.position.y / tileHeight); var thisCol = (sprite.position.x / tileWidth); var thisTile = ((thisRow * rows) + thisCol) + 1; this.game.add.tween(sprite.children[0].scale).to({ x: 0, y: 0}, 500, Phaser.Easing.Linear.None, true); this.game.add.tween(sprite.children[0]).to({alpha: 0}, 500, Phaser.Easing.Linear.None, true); } It seems this works a few times, but then seemingly at random the sprite being passed to the onDown function remains stuck regardless of which sprite I click. I can't be 100% sure, but I think this problem only occurs when I have a child sprite - does that sound right? I've no clue what's going on. Can anyone help?
  5. Hi I have game.input.onDown and mySprite.events.onInputDown listeners in game. I add listener for on game later than on sprite but listener for game triggers before event on sprite. Is there any way i can manipulate event flow. Similar to what we have in DOM events ( event.target event.currentTarget event.preventDefault() event.stopPropagation() ) Can i stop event in game listener (if sprite was clicked too) or force event to trigger on sprite first under some condition?
  6. I am kind of lost in this events system. I have a button which when i press it creates new graphics object. I want to be able to drag this object while the mouse button is down and when I release it this object should be destroyed. Tried several things but I am lost in sending context objects. How this functionality should be done correctly? ( I remember in Flash was easy, just use startDrag() and the newly created object start to follow the mouse as you move it) Here is my sample code which works partially: var horizontalBaffleBtn = null, horzBaffle = null; horizontalBaffleBtn = gameObject.add.button(10, 10, frnConstr.ImageAssetKeys.HORIZONTAL_BAFFLE); horizontalBaffleBtn .events .onInputDown .add(function () { this.frnPart = this .grUtils .drawRect(this.context, gameObject.input.x, gameObject.input.y, 50, thickness, constGr.DEFAULT_GRAPHICS_BORDER_SIZE, constGr.Colors.BLACK, 1, utils.getHexColor(shelveCssColor), 1); this.frnPart.inputEnabled = true; this.frnPart.input.enableDrag(false); this.frnPart.input.start(0, true); }, {context: grContext, grUtils: this, frnPart: horzBaffle}); console.log(horzBaffle);// prints null horizontalBaffleBtn.events.onInputUp.add(function () { this.destroy(); // breaks here, horzBaffle is null }, horzBaffle);
  7. I have an button in my game where I am popping a Facebook share window using Facebook SDK for JavaScript. When I interact with the popup and close it, the entire game show's a hand cursor and behaves as if it is the button. Anywhere I click on the screen will launch the popup again. I found that I can stop this behavior by adding the code at the bottom of this function, but then I have to click on the game to regain its focus before I can click on another button. Anyone have any ideas on how to deal with this? shareThis.inputEnabled = true;shareThis.input.useHandCursor = true;shareThis.events.onInputDown.add(function () { share(shareTitles[level - 1], shareMessages[level - 1], shareImgPath + 'icon_level' + level + '.jpg'); // I can stop the whole game acting like a button thing by doing this... shareThis.inputEnabled = false; shareThis.inputEnabled = true; shareThis.input.useHandCursor = true; // ...but then I have to click on the game once to regain its focus before I can interact with it again});
  8. I have a problem when I get the position of Input (click, touch, etc...) in a event and then try to put a sprite in the same position. This happen when the game is in (100%, 100%) screen mode, i.e , the sprites in a scene are responsive to the screen size. In this case, the position of the sprite is "shifted" a space versus the mouse click, the problem is: this "shift" is not constant, and the image is not exactly in the sprite.x(y) position. More details: I have a image 800 x 600 per example in a sprite, this sprite is responsive to the touch or click event, when this happen, I put a new sprite in the position of the click, but... well, the thing I said at the beginning. Thanks.
  9. Brandybuck

    Fullscreen onInputDown issues

    Hey Guys, I'm new to Phaser and can't wrap my head around something! That's to say, i'm not sure whether i've found a bug or doing something wrong.. Right now i've got this game that wants to go fullscreen. define(function(){ var p = Main.prototype; Main.game = null; Main.juggler = []; function Main() { Main.game = new Phaser.Game(568, 320, Phaser.AUTO, 'holder', { preload: this.preload, create: this.create, update: this.update }); g.game = Main.game } p.preload = function() { Main.game.load.bitmapFont('orangejuice', 'fonts/orangejuice.png', 'fonts/orangejuice.xml'); Main.game.load.image("curtain", "images/curtain.png"); Main.game.load.image("bg-cage", "images/bg-cage.png"); Main.game.load.image("title", "images/title.png"); Main.game.load.image("btn-start", "images/btn-start.png"); Main.game.load.image("tassel", "images/tassel.png"); } p.create = function() { //Main.game.input.onDown.add(function(){ // Main.game.stage.scale.startFullScreen(); //}, this); Main.game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL; //resize your window to see the stage resize too Main.game.stage.scale.setShowAll(); Main.game.stage.scale.refresh(); new Splash(); } p.update = function() { for(key in Main.juggler) Main.juggler[key](); } g.Main = Main; new Main(); });When I un-comment that bit of code, the game enters fullscreen as soon as you click it. (I know that's bad practice, but it's easier to debug this way) Now, in my Splash class I create a single button that will trigger something. define(function(){ var p = Splash.prototype; function Splash() { this.tassel = Main.game.add.sprite(0,0,"tassel"); this.tassel.inputEnabled = true; this.tassel.events.onInputDown.add(this.onTasselClicked, this); } p.onTasselClicked = function(){ alert("you clicked me!"); }})However, when i'm in fullscreen mode, i can't exactly click the button. The hitbox for the onInputDown event stays where it was before going fullscreen. So clicking the actual sprite doesn't trigger anything, but clicking the area where the sprite used to be does. Is this a bug or am i missing something?
  10. Forgive me ahead of time if I miss the obvious. I have been working on a whack-a-mole style game recently and chose Phaser for creating this game. I came across an issue with the 'onInputDown' event that I have applied to a sprite hiding behind another sprite. Basically a person that pops up behind a desk and you whack them with your mouse or touch on a mobile screen. The issue is that I can click on the desk on the layer above the sprite and the 'onInputDown' event triggers. I have searched the forums and online documentation and just can't seem to find any related issue or solution to work from. I am assuming I will kick myself once I find the answer, but any help would be appreciated. So far this platform has been pretty impressive, but I am also coming from a Flash/Actionscript background and this sort of issue isn't a problem in flash. Thanks from a newbie to Phaser! Tony B.
  11. TonyB

    onInputDown issue with sprite layers

    Forgive me ahead of time if I miss the obvious. I have been working on a whack-a-mole style game recently and chose Phaser for creating this game. I came across an issue with the 'onInputDown' event that I have applied to a sprite hiding behind another sprite. Basically a person that pops up behind a desk and you whack them with your mouse or touch on a mobile screen. The issue is that I can click on the desk on the layer above the sprite and the 'onInputDown' event triggers. I have searched the forums and online documentation and just can't seem to find any related issue or solution to work from. I am assuming I will kick myself once I find the answer, but any help would be appreciated. So far this platform has been pretty impressive, but I am also coming from a Flash/Actionscript background and this sort of issue isn't a problem in flash. Thanks from a newbie to Phaser!