vohogames Posted October 2, 2015 Share Posted October 2, 2015 Hi to all, I have coded a 10x10 game clone using Phaser. Here is the address http://www.oyunta.com/1010-blok-tetris/Oyna/I have a problem ( which is very boring on mobile screen) I create stone like below tetris1 = this.game.add.sprite(this.game.width / divider[x], 100 + VohoGame.game.global.startFromY + 10 * VohoGame.game.global.tileSize, 'tetris' + r); tetris1.inputEnabled = true; tetris1.input.enableDrag(/*false, true*/); tetris1.events.onInputDown.add(this.onClick, this); tetris1.events.onDragStart.add(this.startDrag, this); tetris1.events.onDragStop.add(this.stopDrag, this); tetris1.input.enableSnap(90, 90, false, true);My problem in here is the player has to click directly on the image and start dragging. On small screens it is really difficult to point. What i would like to do is split the bottom area in 3 slices. clicking anywhere match the stone on that area. In this game http://m.wellgames.com/game/qualitynew/new/r23639/10x10 , clicking below any stone, the game drags that stone automatically. Thanks in advance. Best regards,Ozgur Link to comment Share on other sites More sharing options...
jmp909 Posted October 3, 2015 Share Posted October 3, 2015 off the top of my head here are a couple of different ideas.. * don't put the event on the individual blocks, put the event on the background underneath and check the X position to work out which sprite you want to pick up and then carry on as usual OR * draw an invisible Phaser.Graphic in the block that's larger than the block sprite = game.add.sprite(100, game.height-150, 'phaser'); var graphic = new Phaser.Graphics(game,0,0); sprite.addChild(graphic); graphic.beginFill(0xFF0000,0) // opacity 0 = invisible but still present graphic.drawRect(0,0,sprite.width, sprite.height*2) // we want some clickable space underneath, so let's have it twice the height of the sprite graphic.endFill(); sprite.inputEnabled = true; sprite.input.enableDrag(false); // false = don't snap the pointer I guess this will slow things down ever so slightly, as it has to draw that hit area, even though it's invisible. but for your sort of game I don't think it'll matter here's the second example abovehttp://phaser.io/sandbox/edit/wRIyuqRY vohogames 1 Link to comment Share on other sites More sharing options...
vohogames Posted October 3, 2015 Author Share Posted October 3, 2015 Thank you jmp909, it works really smooth. This is how i did it, it seems my problem is solved. tetris1.addChild(graphic);graphic.beginFill(0xFF0000,0.1) // showing it but here, but set it to 0graphic.drawRect(-80,-40,tetris1.width*4, tetris1.height*5) jmp909 1 Link to comment Share on other sites More sharing options...
Recommended Posts