SideNode.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. contentNode: {
  14. default: null,
  15. type: cc.Node
  16. },
  17. inviteNode: {
  18. default: null,
  19. type: cc.Node
  20. },
  21. scrollViewNode: {
  22. default: null,
  23. type: cc.Node
  24. },
  25. scrollContentNode: {
  26. default: null,
  27. type: cc.Node
  28. },
  29. friendPrefab: {
  30. default: null,
  31. type: cc.Prefab
  32. },
  33. },
  34. // LIFE-CYCLE CALLBACKS:
  35. onLoad () {
  36. let contentNodeHeight = 130;
  37. let scrollViewNodeHeight = 0;
  38. for (let i = 0; i < 6; i++) {
  39. let temp = cc.instantiate(this.friendPrefab);
  40. this.scrollContentNode.addChild(temp);
  41. scrollViewNodeHeight += 100;
  42. contentNodeHeight += 100;
  43. }
  44. this.contentNode.height = contentNodeHeight;
  45. this.scrollViewNode.height = scrollViewNodeHeight;
  46. },
  47. // update (dt) {},
  48. });