Saturday, September 10, 2022
HomeGame DevelopmentTips on how to change the processing order Node Occasion System? -...

Tips on how to change the processing order Node Occasion System? – Cocos Creator


I’ve 3 sprites, with the assistance of a script I modify the rendering order and drag the sprites one on prime of the opposite in reverse order.
The sprite that was on the backside is obtained from above. However whenever you click on on this stack once more, it’s not potential to take the highest sprite.
Please inform me how can I clear up this downside. I didn’t discover a resolution on the discussion board.

import { _decorator, Part, Node, enter, Enter, Occasion, Vec2, Label, KeyCode, EventMouse, EventTarget} from ‘cc’;
import{GameManager} from “./GameManager”;
const { ccclass, property } = _decorator;

@ccclass(‘TouchDragger’)
export class TouchDragger extends Part {

onLoad() {
  
    this.node.on(Node.EventType.TOUCH_START, (occasion) => { 
    console.log('Contact begin');
    
    occasion.propagationStopped = true;
    
    this.node.setSiblingIndex(2);

    }, this);

    this.node.on(Node.EventType.TOUCH_MOVE, (occasion) => { 
      
    this.node.setPosition(this.node.getPosition().x + occasion.contact.getDelta().x , this.node.getPosition().y + occasion.contact.getDelta().y, 0);
   
    }, this);

    this.node.on(Node.EventType.TOUCH_END, (occasion) => { 
    console.log('Contact finish');

    occasion.propagationStopped = false;
    }, this);

}


It must be like a card sport the place the deck is shuffled and the topmost card could be dragged.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments