node.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. this.do = function () {
  2. //do in step
  3. }
  4. this.step = function () {
  5. if (this.stepping) {
  6. this.do();
  7. }
  8. let t = this.stepTime ? this.stepTime : 0.05;
  9. this.future(t).step();
  10. }
  11. this.clickEvent = function () {
  12. //click event
  13. }
  14. this.mouseupEvent = function () {
  15. //click event
  16. }
  17. this.mousedownEvent = function () {
  18. //click event
  19. }
  20. this.checkForDragStart = function (avatarID) {
  21. let av = this.getScene().findNodeByID(avatarID);
  22. if (this.drag) {
  23. //console.log("DRAG START for ", avatarID)
  24. av.dragID = this.id;
  25. av.delta = [av.x - this.x, av.y - this.y]
  26. }
  27. }
  28. this.checkForDragEnd = function (avatarID) {
  29. if (this.drag) {
  30. // console.log("DRAG END for ", avatarID)
  31. let node = this.getScene().findNodeByID(avatarID);
  32. node.dragID = null;
  33. node.delta = [0, 0]
  34. }
  35. }
  36. this.overstartEvent = function (avatarID) {
  37. //over start
  38. }
  39. this.overendEvent = function (avatarID) {
  40. //over end
  41. }
  42. this.getRandomColor = function () {
  43. var letters = '0123456789ABCDEF';
  44. var color = '#';
  45. for (var i = 0; i < 6; i++) {
  46. color += letters[Math.floor(this.random() * 16)];
  47. }
  48. return color;
  49. }
  50. this.getScene = function () {
  51. let scene = this.find("/")[0];
  52. return scene
  53. }
  54. this.onGlobalBeat = function(obj){
  55. //on global beat
  56. }