buildZone.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Learn cc.Class:
  2. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
  10. cc.Class({
  11. extends: cc.Component,
  12. properties: {
  13. StartPos: cc.v2(),
  14. NextPos1: cc.v2(),
  15. NextPos2: cc.v2(),
  16. NextPos3: cc.v2(),
  17. },
  18. // LIFE-CYCLE CALLBACKS:
  19. // onLoad () {},
  20. start() {
  21. // this.width = 130;
  22. this._DrawParallelogramZone(new cc.Color(255, 255, 255, 100));
  23. },
  24. // update (dt) {},
  25. _DrawParallelogramZone(color) {
  26. var g = this.getComponent(cc.Graphics);
  27. g.lineWidth = 1;
  28. // g.fillColor.fromHEX('#ff0000');
  29. g.fillColor = color;
  30. // g.moveTo(-this.width, 0);
  31. // g.lineTo(0, -this.width * 0.5);
  32. // g.lineTo(this.width, 0);
  33. // g.lineTo(0, this.width * 0.5);
  34. g.moveTo(this.StartPos.x, this.StartPos.y);
  35. g.lineTo(this.NextPos1.x, this.NextPos1.y);
  36. g.lineTo(this.NextPos2.x, this.NextPos2.y);
  37. g.lineTo(this.NextPos3.x, this.NextPos3.y);
  38. g.close();
  39. g.stroke();
  40. g.fill();
  41. },
  42. //设置红色提示
  43. onSetRedSpriteFrame() {
  44. this.Tip.spriteFrame = this.Red;
  45. },
  46. //重新设置图片
  47. onReset() {
  48. this.Tip.spriteFrame = this.Green;
  49. }
  50. });