FMapDialog.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import Home from "../../../home/Home";
  2. import FF from "../../FF";
  3. import WOneByone from "../map1/WOneByone";
  4. /**
  5. * 地图场景中对话
  6. */
  7. export default class FMapDialog {
  8. private ff:FF
  9. //对话框样式
  10. public mMapDialog:cc.Prefab;
  11. constructor(ff:FF,mMapDialog:cc.Prefab){
  12. this.ff = ff;
  13. this.mMapDialog = mMapDialog;
  14. }
  15. public showDialog(dialogs:Array<string>,//对话内容
  16. pos:cc.Vec2,//显示在地图中的位置
  17. spine:sp.Skeleton,//当前动画精灵
  18. callback:()=>void)//对话结束后的回调
  19. {
  20. let node = cc.instantiate(this.mMapDialog);
  21. node.group = 'map'
  22. node.zIndex = 9999;
  23. node.x = pos.x;
  24. node.y = pos.y;
  25. node.parent = this.ff.mMap.mSprites;
  26. let obo = node.getComponent(WOneByone);
  27. this.ff.mBlockInputEvents.active = true;
  28. obo.dialogs = dialogs;
  29. obo.spine = spine;
  30. obo.setCallback(()=>{
  31. node.destroy();
  32. this.ff.setBlockInputCallback(null);
  33. this.ff.mBlockInputEvents.active = false;
  34. callback();
  35. });
  36. this.ff.setBlockInputCallback(()=>{
  37. obo.jump();
  38. });
  39. obo._start();
  40. }
  41. }