Skip to content

Instantly share code, notes, and snippets.

@matrixcloud
Created September 7, 2018 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matrixcloud/92316b035deb5d7f4c6100208ac1e761 to your computer and use it in GitHub Desktop.
Save matrixcloud/92316b035deb5d7f4c6100208ac1e761 to your computer and use it in GitHub Desktop.
// shack screen effect
// @duration
shakeEffect: function (duration) {
this.node.runAction(
cc.repeatForever(
cc.sequence(
cc.moveTo(0.02, cc.p(5, 7)),
cc.moveTo(0.02, cc.p(-6, 7)),
cc.moveTo(0.02, cc.p(-13, 3)),
cc.moveTo(0.02, cc.p(3, -6)),
cc.moveTo(0.02, cc.p(-5, 5)),
cc.moveTo(0.02, cc.p(2, -8)),
cc.moveTo(0.02, cc.p(-8, -10)),
cc.moveTo(0.02, cc.p(3, 10)),
cc.moveTo(0.02, cc.p(0, 0))
)
)
);
setTimeout(() => {
this.node.stopAllActions();
this.node.setPosition(0,0);
}, duration*1000);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment