You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.1 KiB

  1. cc.Scene.ClassName = "Scene";
  2. function cc.Scene:setHeightMap(fileName)
  3. if self:getHeightField() then
  4. self:removeComponent(self:getHeightField());
  5. end
  6. if self:getCollisionObject() then
  7. self:removeComponent(self:getCollisionObject());
  8. end
  9. local heightField = cc.HeightFieldComponent:load(fileName);
  10. self:addComponent(heightField);
  11. end
  12. function cc.Scene:getHeightMap()
  13. local heightField = self:getHeightField();
  14. if not heightField then
  15. return nil;
  16. else
  17. return heightField:getFileName();
  18. end
  19. end
  20. -- 获取一个点的高度信息
  21. -- worldPos为二位坐标点
  22. function cc.Scene:getHeight(x, z)
  23. local heightField = self:getHeightField();
  24. if not heightField then
  25. return 0
  26. end
  27. return heightField:getHeight(x, z)
  28. end
  29. function cc.Scene:loadFromXmlNode(xmlNode)
  30. cc.Node2D.loadFromXmlNode(self , xmlNode);
  31. local fog = xmlNode.Fog;
  32. if fog then
  33. self:setFog(fog);
  34. end
  35. local heightMapFile = xmlNode.HeightMapFile;
  36. if heightMapFile and heightMapFile ~= "" then
  37. self:setHeightMap(heightMapFile);
  38. end
  39. end
  40. function cc.Scene:createNode()
  41. local node = cc.Scene:create();
  42. return node;
  43. end