2
0

Sprite_ScriptBinding.h 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. ConsoleMethodGroupBeginWithDocs(Sprite, SpriteBase)
  23. /*! Sets the sprite texture flipping for each axis.
  24. @param flipX Whether or not to flip the texture along the x (horizontal) axis.
  25. @param flipY Whether or not to flip the texture along the y (vertical) axis.
  26. @return No return value.
  27. */
  28. ConsoleMethodWithDocs(Sprite, setFlip, ConsoleVoid, 4, 4, (bool flipX, bool flipY))
  29. {
  30. // Set Flip.
  31. object->setFlip( dAtob(argv[2]), dAtob(argv[3]) );
  32. }
  33. //-----------------------------------------------------------------------------
  34. /*! Gets the flip for each axis.
  35. @return (bool flipX/bool flipY) Whether or not the texture is flipped along the x and y axis.
  36. */
  37. ConsoleMethodWithDocs(Sprite, getFlip, ConsoleString, 2, 2, ())
  38. {
  39. // Create Returnable Buffer.
  40. char* pBuffer = Con::getReturnBuffer(32);
  41. // Format Buffer.
  42. dSprintf(pBuffer, 32, "%d %d", object->getFlipX(), object->getFlipY());
  43. // Return Buffer.
  44. return pBuffer;
  45. }
  46. //-----------------------------------------------------------------------------
  47. /*! Sets whether or not the texture is flipped horizontally.
  48. @param flipX Whether or not to flip the texture along the x (horizontal) axis.
  49. @return No return value.
  50. */
  51. ConsoleMethodWithDocs(Sprite, setFlipX, ConsoleVoid, 3, 3, (bool flipX))
  52. {
  53. // Set Flip.
  54. object->setFlipX( dAtob(argv[2]) );
  55. }
  56. //-----------------------------------------------------------------------------
  57. /*! Sets whether or not the texture is flipped vertically.
  58. @param flipY Whether or not to flip the texture along the y (vertical) axis.
  59. @return No return value.
  60. */
  61. ConsoleMethodWithDocs(Sprite, setFlipY, ConsoleVoid, 3, 3, (bool flipY))
  62. {
  63. // Set Flip.
  64. object->setFlipY( dAtob(argv[2]) );
  65. }
  66. //-----------------------------------------------------------------------------
  67. /*! Gets whether or not the texture is flipped horizontally.
  68. @return (bool flipX) Whether or not the texture is flipped along the x axis.
  69. */
  70. ConsoleMethodWithDocs(Sprite, getFlipX, ConsoleBool, 2, 2, ())
  71. {
  72. return object->getFlipX();
  73. }
  74. //-----------------------------------------------------------------------------
  75. /*! Gets whether or not the texture is flipped vertically.
  76. @return (bool flipY) Whether or not the texture is flipped along the y axis.
  77. */
  78. ConsoleMethodWithDocs(Sprite, getFlipY, ConsoleBool, 2, 2, ())
  79. {
  80. return object->getFlipY();
  81. }
  82. ConsoleMethodGroupEndWithDocs(Sprite)