luotuo Posted August 18, 2018 Share Posted August 18, 2018 This is my app, use phaser3. the red line area is in one top container . I would like the area move left and right by user finger。 A container How to listen drag even? This is my code, but is not work. StatusBar.create = function() { this.events.on('resize', this.resize, this); this.buttomBanner(); StatusBar.topContainer = this.add.container(0, this.sys.game.config.height - this.height); StatusBar.topContainer.setInteractive(); StatusBar.topContainer.on("drag", function(pointer) { console.log("hit"); }); this.tagUpdate("paper_0"); this.scene.bringToTop(); } } Link to comment Share on other sites More sharing options...
luotuo Posted August 18, 2018 Author Share Posted August 18, 2018 solved StatusBar.topContainer = this.add.container(0, this.sys.game.config.height - this.height); StatusBar.topContainer.setSize(this.sys.game.config.width, this.height); StatusBar.topContainer.key = "top_Container"; StatusBar.topContainer.setInteractive(); this.input.setDraggable(StatusBar.topContainer); //new Phaser.Geom.Rectangle(0, this.sys.game.config.height-this.height, this.width, this.height), Phaser.Geom.Rectangle.Contains this.tagUpdate("paper_0"); this.scene.bringToTop(); StatusBar.topContainer.on('mousemove', function(pointer, gameObject) { console.log('gameobjectover ' + "topContainer"); }); StatusBar.topContainer.on('gameobjectout', function(pointer, gameObject) { console.log('gameobjectout ' + "topContainer"); }); StatusBar.topContainer.on('dragstart', function(pointer, gameObject) { console.log('dragstart ' + "topContainer"); }); StatusBar.topContainer.on('drag', function(pointer, gameObject, dragX, dragY) { console.log('drag ' + "topContainer"); }); StatusBar.topContainer.on('dragend', function(pointer, gameObject) { console.log('dragend ' + "topContainer"); }); StatusBar.topContainer.on('pointerover', function(pointer, gameObject) { console.log('pointerover ' + "topContainer"); }); StatusBar.topContainer.on('pointerout', function(pointer, gameObject) { console.log('pointerout ' + "topContainer"); }); Link to comment Share on other sites More sharing options...
Recommended Posts