espace

How to enable multitouch ? jsfiddle inside

Recommended Posts

Hi,

I have two sprites (button_move and button_fire) with two touchs events. I want to have multitouch enabled : when i press on the same time on the two buttons, normaly the alpha of the two buttons is 0.5. But it’s not working.

I have follow the docs, especially this :
https://rexrainbow.github.io/phaser3-rex-notes/docs/site/index.html/touchevents/ 1
https://labs.phaser.io/index.html?dir=input/multitouch/&q=

And i made a jsfiddle about it :

https://jsfiddle.net/espace3d/vLq08gke/12/ 2

the full code is :

var config = {
    type: Phaser.AUTO,
    width: 480,
    height: 640,
    parent: 'phaser-example',
    input :{
		activePointers:2,
	  },
    scene: {
        create: create,
        update: update
    }
};

var game = new Phaser.Game(config);
var button_move;
var button_fire;
var flag_move=false;
var flag_fire=false;

function create ()
{
	button_move=this.add.sprite(100,100,'image').setInteractive();
	button_move.on('pointerdown',function(pointer1){
		flag_move=true
	})
	button_fire=this.add.sprite(300,100,'image').setInteractive();
	button_fire.on('pointerdown',function(pointer2){
		flag_fire=true
	})
}

function update()
{
 if (flag_move){
  	button_move.alpha=.5
 }
 if (flag_fire){
  	button_fire.alpha=.5
 }
}

Thanks for your help.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.