Sign in to follow this  
Hashasm

disabling multi-select or muti-touch

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

Share this post


Link to post
Share on other sites

hi guys i got it 

i am just playing with z index..

i mean increasing the this.pos.z of the selected object so that i will come on top of all other remaining objects .B)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.