Jump to content

how to loop the function after click a button?


pkchan1987
 Share

Recommended Posts

<html><head><script type="text/javascript" src="build/phaser.min.js"></script><script>var game = new Phaser.Game(1820, 900, Phaser.AUTO, 'phaser-example', { preload: preload, create: create , update: update});var obj1;var obj2;var d=0;function preload() {    game.load.image('obj1', 'cards.png' );    game.load.image('obj2', '4D.png' );    game.load.image('obj3', 'casino.png' );    game.load.image('obj4', 'chips.png' );    game.load.image('obj5', 'all.png' );    game.load.image('button', 'btn_over.png' );}function create() {    obj1 = game.add.sprite(900 ,300, 'obj1');    obj3 = game.add.sprite(600 ,600, 'obj3');    obj4 = game.add.sprite(300 ,300, 'obj4');    obj5 = game.add.sprite(600 ,0, 'obj5');     button = game.add.button(600, 700, 'button', actionOnClick);}function actionOnClick () { 		var p  = new Phaser.Point(obj1.x, obj1.y);		var p2 = new Phaser.Point(600, 300);		var p3 = new Phaser.Point(obj3.x, obj3.y);		var p4 = new Phaser.Point(obj4.x, obj4.y);		var p5 = new Phaser.Point(obj5.x, obj5.y);		p.rotate(p2.x, p2.y, game.math.wrapAngle(d), true); 		p3.rotate(p2.x, p2.y, game.math.wrapAngle(d), true); 		p4.rotate(p2.x, p2.y, game.math.wrapAngle(d), true); 		p5.rotate(p2.x, p2.y, game.math.wrapAngle(d), true); 		obj1.x = p.x;		obj1.y = p.y;		obj3.x = p3.x;		obj3.y = p3.y;   		obj4.x = p4.x;		obj4.y = p4.y;			obj5.x = p5.x;		obj5.y = p5.y;		d += 0.1;}function update() {}</script></head><body></body></html>

Hi all,

 

I.m going to do a lucky draw wheel spin games...but how to loop the "actionOnClick " function after click a button? :ph34r:

how to stop the function after 5 seconds?

above is my code now....does anyone can help me?

 

 

 

post-10725-0-67182800-1411143080.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...