ScreenSound.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. require "Polycode/ScreenEntity"
  2. class "ScreenSound" (ScreenEntity)
  3. function ScreenSound:ScreenSound(...)
  4. if type(arg[1]) == "table" and count(arg) == 1 then
  5. if ""..arg[1]:class() == "ScreenEntity" then
  6. self.__ptr = arg[1].__ptr
  7. return
  8. end
  9. end
  10. for k,v in pairs(arg) do
  11. if type(v) == "table" then
  12. if v.__ptr ~= nil then
  13. arg[k] = v.__ptr
  14. end
  15. end
  16. end
  17. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  18. self.__ptr = Polycore.ScreenSound(unpack(arg))
  19. Polycore.__ptr_lookup[self.__ptr] = self
  20. end
  21. end
  22. function ScreenSound:Update()
  23. local retVal = Polycore.ScreenSound_Update(self.__ptr)
  24. end
  25. function ScreenSound:getSound()
  26. local retVal = Polycore.ScreenSound_getSound(self.__ptr)
  27. if retVal == nil then return nil end
  28. if Polycore.__ptr_lookup[retVal] ~= nil then
  29. return Polycore.__ptr_lookup[retVal]
  30. else
  31. Polycore.__ptr_lookup[retVal] = Sound("__skip_ptr__")
  32. Polycore.__ptr_lookup[retVal].__ptr = retVal
  33. return Polycore.__ptr_lookup[retVal]
  34. end
  35. end
  36. function ScreenSound:__delete()
  37. Polycore.__ptr_lookup[self.__ptr] = nil
  38. Polycore.delete_ScreenSound(self.__ptr)
  39. end