Hello everyone.
I’m making a game similar to fruit ninja and I want add slicing effect on mouse swipe. I am using Graphics component to it but the issue is it is working in desktop browser but not in mobile browser. Does anyone know how to resolve this?
And I would also like to know if there is any other way to achieve the slicing effect.
@slackmoehrle@linrm@muxiandong
I am attaching a screen record of the above behaviour in desktop and mobile browser.
Desktop:
Mobile:
Note: in mobile browser, if we swipe it doesn’t appear but if we hold one finger on screen, use another finger to move, the above result happens.
Ca you please check this?
I did that, but that didn’t help. Even with multi touch disabled, the graphic drawing was not visible on swiping in mobile browsers. This issue is only in mobile browser.
Thank you
In you touch callback, you can retrieve the touch id with touch.getID(), then filter the touches with original id you saved in touch start, remember not to override the touch id before touch end
I tried this, but didn’t work.
I replicated the same in cocos creator 2.4.4, there it works fine in mobile and desktop browser. but in creator 3.4.1 this is happening.
Can you please take a look at this code once?
Thank you
I fix this problem when I remove the code in update phase in Game.ts
maybe you can take a look into this part of code.
update(dt: number) {
// When the sliding speed is slow, it will not disappear quickly
// if (this.drawPoints.length < 30) {
// for (let i = 0; i < 1; i++) {
// if (this.drawPoints.length > 0) {
// this.drawPoints.shift();
// } else {
// break;
// }
// }
// } else {
// for (let i = 0; i < 9; i++) {
// if (this.drawPoints.length > 0) {
// this.drawPoints.shift();
// } else {
// break;
// }
// }
// // In order to keep lines from being too long
// while (this.drawPoints.length > 400) {
// this.drawPoints.shift();
// }
// }
}
@PP_Pro Can you please suggest me on how to improve that effect? Sometimes while moving the effect won’t be solid like there will be gaps between them.