Jump to content

Dragging item


vohogames
 Share

Recommended Posts

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

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 above

http://phaser.io/sandbox/edit/wRIyuqRY

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...