Jump to content

disabling multi-select or muti-touch


Hashasm
 Share

Recommended Posts

hi all,

its going well with melonjs in building of my game ...

can someone help me how to disable the multi-touch form draggable entity .

i am trying to releasePointerEvent while dragmove but like this me.input.releasePointerEvent("pointerdown",this);   but i am failing to register my pointer down event again ..

can some one help me with this ....

here is my code for reference..

i am detecting collision also  ...so the problem arise when i am dropping my asset on collision part(another asset) it will detect collision and it wont drop and my asset will follow the pointer till i drop it on non collision zone if instead of dropping if i am selecting other asset it selecting other asset also along with my previous asset then i cant drop both because its colliding with each other ..

this is what happening i trying all ways but i am not getting it can someone suggest me how to handle this thank you

game.mycopy = me.DraggableEntity.extend({
    init: function (x, y, settings) {

        var image = settings.image;
        var framewidth = settings.width;
        var framewidth = settings.height;

        // console.log("Dragged !!!!!!!!!!!!!!!!!!!!!!!!");
        this._super(me.DraggableEntity, "init", [x, y, settings]);
        console.log(camera);
        me.game.world.removeChild(camera);
       /* var texture = new me.video.renderer.Texture({
                framewidth: 268,
                frameheight: 296
            },
            me.loader.getImage(image)
        );
       
        // create a new animationSheet object
        this.renderable = texture.createAnimationFromName([0, 1, 2, 3, 4, 5, 6, 7]);
        // define a basic walking animation (using all frames)
        this.renderable.addAnimation("walk", [0, 1, 2, 3, 4, 5, 6, 7]);

        // define a standing animation (using the first frame)
        this.renderable.addAnimation("stand", [0]);

        // set the standing animation as default
        this.renderable.setCurrentAnimation("stand");*/

        this.xcor = x;
        this.ycor = y;
//        this.anchorPoint.set(0, 0);
        this.isHoldable = false;
        this.hover = false;
        this.entityselected = false;

        var settle = {};
        this.settle = settings;


        // console.log("settings" + JSON.stringify(settings));

    },

    update: function () {

        return true;
    },
    //code for removing collision object
    onActivateEvent: function (event) {
        // register on the 'pointerdown' event

 me.input.registerPointerEvent('pointerdown', this, this.pointerSelect.bind(this));
   

    },


    pointerSelect: function (event) {
        
        
                if (event.button === 0) {
                     console.log(this._super(me.DraggableEntity, "dragMove", [event]))
                      console.log("this entity is selected");
        console.log(this);
        /*this.oldx=this.pos.x;
                        this.oldy=this.pos.y;
                        this.oldrow=tile.row;
                        this.oldcol=tile.col;*/
        /* if(event.type == "mousedown" ){
            //this.entityselected = false;
    $("#cbp-spmenu-s2").addClass("cbp-spmenu-open");
        }
     */
        this.isHoldable = true;
        this.hover = true;
        this.entityselected = true;
        this._super(me.DraggableEntity, "dragStart", [event]);

        if (me.levelDirector.getCurrentLevelId()) {
            var layer = me.game.world.getChildByName("ground")[0];
            var tile = layer.getTile(event.gameX, event.gameY);
            if (tile) {
           
                 return false;
                  } 
            else if (event.button === 2) {
                    //right click
                      console.log("right click");
                       $("#cbp-spmenu-s2").addClass("cbp-spmenu-open");
                  } else {
                    //mouse wheel
                       console.log("wheel click");
                  }
      


             
            }
        }

        // don"t propagate the event to other objects
//        return false;
    },
    dragStart: function (event) {

        if (this.entityselected === true) {
if (event.button === 2) {
                    //right click
                      console.log("right click");
                       $("#cbp-spmenu-s2").addClass("cbp-spmenu-open");
                  }
            else{
            this._super(me.DraggableEntity, "dragStart", [event]);
            console.log("drag dragstart");
            console.log(event);
            
            this.isHoldable = true;
            this.hover = true;
            this.entityselected = true;
                
            }

        }
        //return false;
    },
    dragMove: function (event) {
        console.log("event" + event.type);
       // console.log("event" + event.type);

        if (this.entityselected === true) {
           
        
            // me.input.releasePointerEvent("pointerdown",this);   ///////////trying to release Pointer event
            
            console.log(this)
            this.isHoldable = true;
            this.hover = true;
            this.entityselected = true;
            this._super(me.DraggableEntity, "dragMove", [event]);
            //me.game.viewport.follow(this.pos, me.game.viewport.AXIS.BOTH);

            me.collision.check(this)


        }
        //return false;

    },
    dragEnd: function (event) {

        var x, y;

        if (this.entityselected === true) {
           

            if (me.levelDirector.getCurrentLevelId()) {
                var layer = me.game.world.getChildByName("ground")[0];
                var tile = layer.getTile(event.gameX, event.gameY);
                if (tile) {
                    if (me.collision.check(this) === false) {

                        this._super(me.DraggableEntity, "dragEnd", [event]);
                        console.log("drag end");
// me.input.registerPointerEvent('pointerdown', this, this.pointerSelect.bind(this));
                        
                        
                        x = this.pos.x;
                        y = this.pos.y;
                       this.isHoldable = false;
                this.hover = false;
        this.entityselected = false; 
                     

                   

                    }
                }
            }
        }
        me.collision.check(this);
    },
   
    onCollision: function (response, other) {
        // Make all other objects solid
      
        return false;
    }
});

Link to comment
Share on other sites

  • 2 weeks later...

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...
 Share

  • Recently Browsing   0 members

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