ChatBubble.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. cc.Class({
  2. extends: cc.Component,
  3. properties:
  4. {
  5. m_Bubble: cc.Node,
  6. m_ChatBG: cc.Sprite,
  7. m_ChatLabel: cc.Label,
  8. m_Position: cc.Vec2,
  9. m_AnchorPoint: cc.Vec2,
  10. m_Scale: cc.Vec2,
  11. },
  12. ctor :function(){
  13. this.m_bActionFinish = true;
  14. },
  15. start :function(){
  16. this.node.setScale(0, 0);
  17. },
  18. ShowBubble :function(szText)
  19. {
  20. if(!this.m_bActionFinish) return false;
  21. this.m_bActionFinish = false;
  22. var szTextTemp = szText;
  23. this.m_ChatLabel.string = szTextTemp;
  24. var sizeContent = cc.size(0, 0);
  25. sizeContent.width = this.m_ChatLabel.node.getContentSize().width + 30;
  26. sizeContent.height = this.m_ChatLabel.node.getContentSize().height;
  27. this.m_ChatBG.node.setContentSize(sizeContent);
  28. this.node.setContentSize(sizeContent);
  29. this.node.setScale(0, 0);
  30. //var pScaleTo = cc.scaleTo(0.1, this.m_Scale.x, this.m_Scale.y);
  31. var pScaleTo = cc.scaleTo(0.1, 1, 1);
  32. this.node.runAction(cc.sequence(pScaleTo, cc.delayTime(3), cc.scaleTo(0.1, 0, 0), cc.delayTime(2), cc.callFunc(this.OnShowBubbleCallBack, this) ) );
  33. return true;
  34. },
  35. OnAnimationCallBack:function(){
  36. this.m_bActionFinish = true;
  37. },
  38. GetBubbleActionStatus :function()
  39. {
  40. return this.m_bActionFinish;
  41. }
  42. });