Sign in to follow this  
luotuo

A container How to listen drag even?

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();
        
       

        


    }

        


    }

 

Share this post


Link to post
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");

        });

 

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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.