场景抖动


场景抖动

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
sceneShock(times){
let scene = cc.director.getScene();
scene.runAction(
cc.sequence(
cc.repeat(cc.sequence(cc.delayTime(1/30), cc.callFunc(() => {
scene.x = Math.random() * 20 * (Math.random()>0.5?1:-1);
scene.y = Math.random() * 20 * (Math.random()>0.5?1:-1);
})), times),
cc.callFunc(() => {
scene.x = 0;
scene.y = 0;
})
)
);
};