BaseGameStates.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. },
  5. onLoad() {
  6. this.restTime = 0;
  7. this.currentTime = 0;
  8. this.player_name = "";
  9. this.player_gold = 0;
  10. this.player_energy = 0;
  11. this.player_sex = 0;
  12. },
  13. start() {
  14. this.InformationChanges("set", 0, "AFHRFS");
  15. this.InformationChanges("set", 1, 50);
  16. this.InformationChanges("set", 2, 50);
  17. },
  18. // update (dt) {},
  19. InformationChanges(state, indel, info) {
  20. if (state == "set") {
  21. if (indel == 0) {
  22. this.player_name = info;
  23. }
  24. if (indel == 1) {
  25. this.player_gold = info;
  26. }
  27. if (indel == 2) {
  28. this.player_energy = info;
  29. }
  30. if (indel == 3) {
  31. this.player_sex = info;
  32. }
  33. } else if (state == "get") {
  34. if (indel == 0) {
  35. return this.player_name;
  36. }
  37. if (indel == 1) {
  38. return this.player_gold;
  39. }
  40. if (indel == 2) {
  41. return this.player_energy;
  42. }
  43. if (indel == 3) {
  44. return this.player_sex;
  45. }
  46. }
  47. }
  48. });