Drag And Drop how can we close raycast target property of an object

Unity Raycast Targat image link I have to close raycast target property as in unity3D, if i cant accomplish it i will hit my head to the wall , Please help me for god’s sake

Can you pls elaborate what exactly you are trying to achieve here(except planning on banging you head on wall :face_with_head_bandage:) ? Do you want to extend property panel and add that particular checkbox, or if you are after the functionality of it? What code/methods you have tried already?

https://youtu.be/Oy31zeUChc4 error Helpmi :slight_smile:

Do you want colision detection?
http://docs.cocos.com/creator/manual/en/physics/collision/

Do you want blocks behind yours to get the mouse event?
http://docs.cocos.com/creator/manual/en/scripting/internal-events.html

I am lost, i still don’t have any idea what is it you are looking for. Share some objective.

  1. Do you want to block touch events of certain UI elements(Two boxes can receive touches while third one should not, until two are visible)?
  2. Do you want only certain UI elements to receive touch events(layered structured)

what methods you tried already?

Lazy_Gamer Yes 1 :slight_smile: Prevent clicking

Helmpi —> https://youtu.be/q_WzG99B86A

You can use buttons for your UI events refer this video, its in korean(i guess) but you will get the idea.

set interactable to false(see property panel on right) when button don’t needs to be intractable.
enable/disable button from code:-
mybutton.enable = true/false;

Sometimes you want to implement UI elements in a manner where other UI elements are behind your components with event listeners. To block touch bubbling to them you can use a dummy node as parent set its size to your view-port and stop propagation like this.node.stopPropagation(). This is similar like putting your elements on a layer and swallowing touches on that layer so that elements behind it won’t receive events.

Also you can refer this video to learn more about setup


use auto translate feature of youtube to translate video language

SuperDragAndDrop

I wanna normal drag & drop but i need to detect Shape I. If i drag my item on Shape I , Shape I’s color will be blue. How can i detect Shape I while holding my item.

http://cocos2d-x.org/docs/creator/manual/en/scripting/internal-events.html#touch-event-types-and-event-objects

I am assuming you are using above events, in your cc.Node.EventType.TOUCH_MOVE callback funciton you can do the following depending upon your situation.
Case1:- Your drag-able area and dragged node lies in same node tree and are siblings to eachother(Both have same parent node)

let rect1 = dragArea.getBoundingBox() // change this line to suit your needs to get right area for you.
let rect2 = draggedNode.getBoundingBox() // change this line to suit your needs to get right area for you.
if(rect1.contains(rect2)){
    // we have a overlap do your logic here...
}

Case2:- If both the nodes are on different Node tree(having different parents)

let rect1 = dragArea.getBoundingBox() // change this line to suit your needs to get right area for you.
let rect2 = draggedNode.getBoundingBox() // change this line to suit your needs to get right area for you.
rect2 = this.convertToWorldSpace(rect2);
rect1 = this.convertToWorldSpace(rect1);
    if(rect1.contains(rect2)){
        // we have a overlap do your logic here...
    }

More about transforms in cocos

http://www.cocos2d-x.org/docs/creator/api/en/classes/Rect.html#contain

or you can also look into build in collision Manager if want to learn more about engine.
http://docs.cocos.com/creator/api/en/classes/Collider.html
http://docs.cocos.com/creator/api/en/classes/CollisionManager.html
http://docs.cocos.com/creator/api/en/classes/Collider.Box.html

Usage:- http://cocos2d-x.org/docs/creator/manual/en/physics/collision/collision-manager.html

Thank you :slight_smile: How do you get the mouse position from anywhere?

refer 1st link in my previous answer and scroll up. You will see the usage.

we can reach everywhere in the sources here do not give mouse positions

Help Help get mouse postion

Please, read the manual: http://docs.cocos.com/creator/manual/en/scripting/events.html

There are a lot of example code in the manual and whole projects (games) made: http://docs.cocos.com/creator/manual/en/

Here is a snippet from my game:

cc.Class({
    extends: cc.Component,

    comecaToque(eventoToque) {
        // This will convert the global coordinate to local, if you click in the center of the node it will be (0, 0)
        let toque = this.node.convertTouchToNodeSpaceAR(eventoToque);
        // eventoToque.getLocation() will give the global coordinates
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        // Register the click on the canvas
        cc.Canvas.instance.node.on(cc.Node.EventType.TOUCH_START, this.comecaToque, this);
    }

});

Thank you Gabriini :slight_smile: I’ve read it many times but I understood :slight_smile: how can i typescript :slight_smile: get mouse poses globally

const {ccclass, property} = cc._decorator; // Introduce ccclass and property from the cc._decorator namespace

@ccclass // use decorator to declare CCClass
export default class MyGameManager extends cc.Component { // ES6 Classes declaration syntax, inherited cc.Component

    comecaToque(eventoToque: cc.Touch) {
        let toque: cc.Vec2 = eventoToque.getLocation();
    }

    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        // Register the click on the canvas
        cc.Canvas.instance.node.on(cc.Node.EventType.TOUCH_START, this.comecaToque, this);
    }
}

Thank you my frend :slight_smile: :slight_smile: :slight_smile: :slight_smile: