Jump to content

A container How to listen drag even?


luotuo
 Share

Recommended Posts

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? 

AAAA.thumb.png.e9d039e323fd23a2ba645ed2086c178f.png

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

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

 Share

  • Recently Browsing   0 members

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