Sprite_ScriptBinding.h 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. ConsoleMethod(Sprite, setFlip, void, 4, 4, "(bool flipX, bool flipY) Sets the sprite texture flipping for each axis.\n"
  23. "@param flipX Whether or not to flip the texture along the x (horizontal) axis.\n"
  24. "@param flipY Whether or not to flip the texture along the y (vertical) axis.\n"
  25. "@return No return value.")
  26. {
  27. // Set Flip.
  28. object->setFlip( dAtob(argv[2]), dAtob(argv[3]) );
  29. }
  30. //-----------------------------------------------------------------------------
  31. ConsoleMethod(Sprite, getFlip, const char*, 2, 2, "() Gets the flip for each axis.\n"
  32. "@return (bool flipX/bool flipY) Whether or not the texture is flipped along the x and y axis.")
  33. {
  34. // Create Returnable Buffer.
  35. char* pBuffer = Con::getReturnBuffer(32);
  36. // Format Buffer.
  37. dSprintf(pBuffer, 32, "%d %d", object->getFlipX(), object->getFlipY());
  38. // Return Buffer.
  39. return pBuffer;
  40. }
  41. //-----------------------------------------------------------------------------
  42. ConsoleMethod(Sprite, setFlipX, void, 3, 3, "(bool flipX) Sets whether or not the texture is flipped horizontally.\n"
  43. "@param flipX Whether or not to flip the texture along the x (horizontal) axis."
  44. "@return No return value.")
  45. {
  46. // Set Flip.
  47. object->setFlipX( dAtob(argv[2]) );
  48. }
  49. //-----------------------------------------------------------------------------
  50. ConsoleMethod(Sprite, setFlipY, void, 3, 3, "(bool flipY) Sets whether or not the texture is flipped vertically.\n"
  51. "@param flipY Whether or not to flip the texture along the y (vertical) axis."
  52. "@return No return value.")
  53. {
  54. // Set Flip.
  55. object->setFlipY( dAtob(argv[2]) );
  56. }
  57. //-----------------------------------------------------------------------------
  58. ConsoleMethod(Sprite, getFlipX, bool, 2, 2, "() Gets whether or not the texture is flipped horizontally.\n"
  59. "@return (bool flipX) Whether or not the texture is flipped along the x axis.")
  60. {
  61. return object->getFlipX();
  62. }
  63. //-----------------------------------------------------------------------------
  64. ConsoleMethod(Sprite, getFlipY, bool, 2, 2, "() Gets whether or not the texture is flipped vertically."
  65. "@return (bool flipY) Whether or not the texture is flipped along the y axis.")
  66. {
  67. return object->getFlipY();
  68. }