[ad_1]
I’ve 3 sprites, with the assistance of a script I alter 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. But if you click on on this stack once more, it’s not doable to take the highest sprite.
Please inform me how can I clear up this downside. I didn’t discover a answer on the discussion board.
import { _decorator, Component, Node, enter, Input, Event, Vec2, Label, KeyCode, EventMouse, EventGoal} from ‘cc’;
import{GameManager} from “./GameManager”;
const { ccclass, property } = _decorator;
@ccclass(‘TouchDragger’)
export class TouchDragger extends Component {
onLoad() {
this.node.on(Node.EventKind.TOUCH_START, (occasion) => {
console.log('Touch begin');
occasion.propagationStopped = true;
this.node.setSiblingIndex(2);
}, this);
this.node.on(Node.EventKind.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.EventKind.TOUCH_END, (occasion) => {
console.log('Touch finish');
occasion.propagationStopped = false;
}, this);
}
It must be like a card recreation the place the deck is shuffled and the topmost card could be dragged.
Which model is used? Can you present a easy demo? Every node is registered for occasions?
Version 3.6. I connect the introduced script to every of the three nodes. So far that is an experiment with three sprites. I created nodes each within the editor and denamically within the script,
however the end result is identical – this.node.setSiblingIndex(2) adjustments the rendering order, however doesn’t bear in mind the occasion processing order, and if you click on on the visually prime sprite once more, the outdated node processing order is preserved.
Nodes/sprites are brothers. Tried making them kids of the Canvas or kids of the kid node of the Canvas, the end result is identical. In earlier variations of the engine – goal.setLocalZOrder(1) – solved the issue.
I’ll be glad about any assist!
occasion.propagationStopped = true;
→ occasion.preventSwallow = true;
Maybe you want this
I exploit this in a script, doesn’t clear up the issue!
This is a bug, has created a problem.
when you want,you may delete this code, and recompile engine.
Sorting could be time consuming and should have an effect on efficiency.
File path:3.6.0resourcesresources3denginecocos2deventpointer-event-dispatcher.ts
Koei, thanks on your assist! I hope the builders repair the bug. I feel sorting is likely one of the predominant features.
[ad_2]