SpineObject_ScriptBinding.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  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(SpineObject, SceneObject)
  23. /*! Sets the spine asset Id to use.
  24. @param spineAssetId Integer - The spine asset Id to use.
  25. @return No return value.
  26. */
  27. ConsoleMethodWithDocs(SpineObject, setSpineAsset, ConsoleVoid, 3, 3, (int spineAssetId))
  28. {
  29. object->setSpineAsset(argv[2]);
  30. }
  31. //-----------------------------------------------------------------------------
  32. /*! Gets the spine asset Id.
  33. @return Integer - The spine asset Id.
  34. */
  35. ConsoleMethodWithDocs(SpineObject, getSpineAsset, ConsoleString, 2, 2, ())
  36. {
  37. return object->getSpineAsset();
  38. }
  39. //-----------------------------------------------------------------------------
  40. /*! Sets the animation time scale factor.
  41. @param timeScale Float - The factor by which to multiply the base time scale as
  42. set in the animation.
  43. @return Float - The previous value of the time scale.
  44. */
  45. ConsoleMethodWithDocs(SpineObject, setTimeScale, ConsoleFloat, 3, 3, (float timeScale))
  46. {
  47. return object->setTimeScale(dAtof(argv[2]));
  48. }
  49. //-----------------------------------------------------------------------------
  50. /*! Gets the animation time scale.
  51. @return Float - The current animation time factor.
  52. */
  53. ConsoleMethodWithDocs(SpineObject, getTimeScale, ConsoleFloat, 2, 2, ())
  54. {
  55. return object->getTimeScale();
  56. }
  57. //-----------------------------------------------------------------------------
  58. /*! Sets the animation for the object.
  59. @param animationName String - containing animation name to run.
  60. @param track Int - Optional. Track to run animation in. Defaults to zero.
  61. @param loop Bool - Optional. Determines whether the animation should loop. Defaults to false.
  62. @param mixDuration Float - Optional. The amount of time in seconds to transition (or mix) from the
  63. previously running animation to this one being set. If not set, it defaults to the value set
  64. using the setMix() method. If nothing was defined via setMix, then it defaults to zero, which means
  65. no transition, an abrupt change.
  66. @return Return Bool - True on success.
  67. */
  68. ConsoleMethodWithDocs(SpineObject, setAnimation, ConsoleBool, 3, 6, (char *animationName, [int track, bool loop, float mixDuration]))
  69. {
  70. // Determine looping
  71. int track = argc >= 4 ? dAtoi(argv[3]) : 0;
  72. bool shouldLoop = argc >= 5 ? dAtob(argv[4]) : false;
  73. F32 mixDuration = argc >= 6 ? dAtof(argv[5]) : -1.0f;
  74. return object->setAnimation(argv[2], track, shouldLoop, mixDuration);
  75. }
  76. //-----------------------------------------------------------------------------
  77. /*! Sets the empty animation on the object. This is mainly used to fade into and out of the pose
  78. position, but can be used for whatever.
  79. @param track Int - Optional. Track to run animation in. Defaults to zero.
  80. @param mixDuration Float - Optional. The amount of time in seconds to transition from the
  81. currently running animation to this one.
  82. @return Return Bool - True on success.
  83. */
  84. ConsoleMethodWithDocs(SpineObject, setEmptyAnimation, ConsoleBool, 2, 4, ([int track, float mixDuration]))
  85. {
  86. int track = argc >= 3 ? dAtoi(argv[2]) : 0;
  87. F32 mixDuration = argc >= 4 ? dAtof(argv[3]) : 0.0f;
  88. return object->setEmptyAnimation(track, mixDuration);
  89. }
  90. //-----------------------------------------------------------------------------
  91. /*! Queues the animation for the object. The queued animation will play after the currently
  92. playing animation completes.
  93. @param animationName String - Contains the name of the animation to queue.
  94. @param track Int - Optional. Track to run in. Defaults to zero. Animations can be layered in
  95. different tracks.
  96. @param loop Boolean - Optional. Indicates if animation should loop once it's processed.
  97. @param mixDuration Float - Optional. The amount of time in seconds to transition from the
  98. currently running animation to this one.
  99. @param delay Float - Optional. Indicates a lag (leading or trailing) between this and
  100. the currently running animation. In seconds.
  101. @return Returns Bool - True on success.
  102. */
  103. ConsoleMethodWithDocs(SpineObject, queueAnimation, ConsoleBool, 3, 7, (char *animationName, [int track, bool loop, float mixDuration, float delay]))
  104. {
  105. int track = argc >= 4 ? dAtoi(argv[3]) : 0;
  106. bool shouldLoop = argc >= 5 ? dAtob(argv[4]) : false;
  107. F32 mixDuration = argc >= 6 ? dAtof(argv[5]) : -1.0f;
  108. F32 delay = argc >= 7 ? dAtof(argv[6]) : 0.0f;
  109. return object->queueAnimation(argv[2], track, shouldLoop, mixDuration, delay);
  110. }
  111. //-----------------------------------------------------------------------------
  112. /*! Queues the empty animation on the object. Useful for fading and transitions.
  113. @param track Int - Optional. Track to run animation in. Defaults to zero.
  114. @param mixDuration Float - Optional. The amount of time in seconds to transition from the
  115. currently running animation to this one.
  116. @param delay Float - Optional. Indicates a lag (leading or trailing) between this and
  117. the currently running animation. In seconds. Defaults to zero.
  118. @return Return Bool - True on success.
  119. */
  120. ConsoleMethodWithDocs(SpineObject, queueEmptyAnimation, ConsoleBool, 2, 5, ([int track, float mixDuration, float delay]))
  121. {
  122. int track = argc >= 3 ? dAtoi(argv[2]) : 0;
  123. F32 mixDuration = argc >= 4 ? dAtof(argv[3]) : 0.0f;
  124. F32 delay = argc >= 5 ? dAtof(argv[4]) : 0.0f;
  125. return object->queueEmptyAnimation(track, mixDuration, delay);
  126. }
  127. //-----------------------------------------------------------------------------
  128. /*! Clears animations (running and queued) from the given track.
  129. @param track Int - Optional. Track to clear animations from. Defaults to zero.
  130. @param mixToSetup Bool - Optional. If true the track will fade back to the setup pose
  131. over the number of seconds specified in the mixDuration argument.
  132. @param mixDuration Float - Optional. The amount of time in seconds to transition back to
  133. the setup pose.
  134. @return No return value.
  135. */
  136. ConsoleMethodWithDocs(SpineObject, clearAnimations, ConsoleVoid, 2, 5, ([int track, bool mixToSetup, float mixDuration]))
  137. {
  138. int track = argc >= 3 ? dAtoi(argv[2]) : 0;
  139. bool mixToSetup = argc >= 4 ? dAtob(argv[3]) : false;
  140. F32 mixDuration = argc >= 5 ? dAtof(argv[4]) : 0.0f;
  141. object->clearAnimations(track, mixToSetup, mixDuration);
  142. }
  143. //-----------------------------------------------------------------------------
  144. /*! Clears animations (running and queued) from all tracks.
  145. @param mixToSetup Bool - Optional. If true the character will fade back to the setup pose
  146. over the number of seconds specified in the mixDuration argument.
  147. @param mixDuration Float - Optional. The amount of time in seconds to transition back to
  148. the setup pose.
  149. @return No return value.
  150. */
  151. ConsoleMethodWithDocs(SpineObject, clearAllAnimations, ConsoleVoid, 2, 4, ([bool mixToSetup, float mixDuration]))
  152. {
  153. bool mixToSetup = argc >= 3 ? dAtob(argv[2]) : false;
  154. F32 mixDuration = argc >= 4 ? dAtof(argv[3]) : 0.0f;
  155. object->clearAllAnimations(mixToSetup, mixDuration);
  156. }
  157. //-----------------------------------------------------------------------------
  158. /*! Gets the name of the animation currently running in the given track.
  159. @param track Int - Optional. Track to get name from. Defaults to zero.
  160. @return String - Contains the animation name.
  161. */
  162. ConsoleMethodWithDocs(SpineObject, getAnimationName, ConsoleString, 2, 3, ([int track]))
  163. {
  164. int track = argc >= 3 ? dAtoi(argv[2]) : 0;
  165. return object->getAnimationName(track);
  166. }
  167. //-----------------------------------------------------------------------------
  168. /*! Check if the animation currently running on the given track is looping.
  169. @param track Int - Optional. Track to check. Defaults to zero.
  170. @return Bool - True if current animation is looping. False if there is no animation
  171. running or there is but it is not looping.
  172. */
  173. ConsoleMethodWithDocs(SpineObject, getIsLooping, ConsoleBool, 2, 3, ([int track]))
  174. {
  175. int track = argc >= 3 ? dAtoi(argv[2]) : 0;
  176. return object->getIsLooping(track);
  177. }
  178. //-----------------------------------------------------------------------------
  179. /*! Sets the animation mix time to be used when transitioning between two
  180. animations. This is the amount of time that will be spent morphing
  181. between the from and to animations.
  182. @param fromAnimation String - The name of the animation transitioning from.
  183. @param toAnimation String - The name of the animation transitioning to.
  184. @param mixDuration Float - The number of seconds to spend in the transition.
  185. @return Returns Bool - True on success.
  186. */
  187. ConsoleMethodWithDocs(SpineObject, setMix, ConsoleBool, 5, 5, (char *fromAnimation, char *toAnimation, float mixDuration))
  188. {
  189. Con::printf("Mixing %s with %s at %f", argv[2], argv[3], dAtof(argv[4]));
  190. return object->setMix(argv[2], argv[3], dAtof(argv[4]));
  191. }
  192. //-----------------------------------------------------------------------------
  193. /*! Sets the skin for the spine object.
  194. @param skinName String - Name of the skin (as defined in the animation data) to apply.
  195. @return No return value.
  196. */
  197. ConsoleMethodWithDocs(SpineObject, setSkin, ConsoleVoid, 3, 3, (char *skinName))
  198. {
  199. object->setSkin(argv[2]);
  200. }
  201. //-----------------------------------------------------------------------------
  202. /*! Gets the name of the skin currently applied to the spine object.
  203. @return String - The currently applied skin name.
  204. */
  205. ConsoleMethodWithDocs(SpineObject, getSkinName, ConsoleString, 2, 2, ())
  206. {
  207. return object->getSkinName();
  208. }
  209. //-----------------------------------------------------------------------------
  210. /*! Sets scaling of the spine object's skeleton.
  211. @param scaleX Float - X factor.
  212. @param scaleY Float - Y factor.
  213. @return No return value.
  214. */
  215. ConsoleMethodWithDocs(SpineObject, setScale, ConsoleVoid, 3, 4, (float scaleX, float scaleY))
  216. {
  217. F32 scaleX, scaleY;
  218. const U32 elementCount = Utility::mGetStringElementCount(argv[2]);
  219. // ("width height")
  220. if ((elementCount == 2) && (argc == 3))
  221. {
  222. scaleX = dAtof(Utility::mGetStringElement(argv[2], 0));
  223. scaleY = dAtof(Utility::mGetStringElement(argv[2], 1));
  224. }
  225. // (width, [height])
  226. else if (elementCount == 1)
  227. {
  228. scaleX = dAtof(argv[2]);
  229. if (argc > 3)
  230. scaleY = dAtof(argv[3]);
  231. else
  232. scaleY = scaleX;
  233. }
  234. // Invalid
  235. else
  236. {
  237. Con::warnf("SpineObject::setScale() - Invalid number of parameters!");
  238. return;
  239. }
  240. // Set Scale.
  241. object->setScale(Vector2(scaleX, scaleY));
  242. }
  243. //-----------------------------------------------------------------------------
  244. /*! Gets the spine object's skeleton scale.
  245. @return (float x/y height) The x and y scale of the object's root bone.
  246. */
  247. ConsoleMethodWithDocs(SpineObject, getScale, ConsoleString, 2, 2, ())
  248. {
  249. return object->getScale().scriptThis();
  250. }
  251. //-----------------------------------------------------------------------------
  252. /*! Sets the sprite texture flipping for each axis.
  253. @param flipX Bool - Whether or not to flip the texture along the x (horizontal) axis.
  254. @param flipY Bool - Whether or not to flip the texture along the y (vertical) axis.
  255. @return No return value.
  256. */
  257. ConsoleMethodWithDocs(SpineObject, setFlip, ConsoleVoid, 4, 4, (bool flipX, bool flipY))
  258. {
  259. // Set Flip.
  260. object->setFlip(dAtob(argv[2]), dAtob(argv[3]));
  261. }
  262. //-----------------------------------------------------------------------------
  263. /*! Gets the flip for each axis.
  264. @return (bool flipX/bool flipY) Whether or not the texture is flipped along the x and y axes.
  265. */
  266. ConsoleMethodWithDocs(SpineObject, getFlip, ConsoleString, 2, 2, ())
  267. {
  268. // Create Returnable Buffer.
  269. char* pBuffer = Con::getReturnBuffer(32);
  270. // Format Buffer.
  271. dSprintf(pBuffer, 32, "%d %d", object->getFlipX(), object->getFlipY());
  272. // Return Buffer.
  273. return pBuffer;
  274. }
  275. //-----------------------------------------------------------------------------
  276. /*! Sets whether or not the texture is flipped horizontally.
  277. @param flipX Bool - Whether or not to flip the texture along the x (horizontal) axis.
  278. @return No return value.
  279. */
  280. ConsoleMethodWithDocs(SpineObject, setFlipX, ConsoleVoid, 3, 3, (bool flipX))
  281. {
  282. // Set Flip.
  283. object->setFlipX(dAtob(argv[2]));
  284. }
  285. //-----------------------------------------------------------------------------
  286. /*! Sets whether or not the texture is flipped vertically.
  287. @param flipY Bool - Whether or not to flip the texture along the y (vertical) axis.
  288. @return No return value.
  289. */
  290. ConsoleMethodWithDocs(SpineObject, setFlipY, ConsoleVoid, 3, 3, (bool flipY))
  291. {
  292. // Set Flip.
  293. object->setFlipY(dAtob(argv[2]));
  294. }
  295. //-----------------------------------------------------------------------------
  296. /*! Gets whether or not the texture is flipped horizontally.
  297. @return (bool flipX) Whether or not the texture is flipped along the x axis.
  298. */
  299. ConsoleMethodWithDocs(SpineObject, getFlipX, ConsoleBool, 2, 2, ())
  300. {
  301. return object->getFlipX();
  302. }
  303. //-----------------------------------------------------------------------------
  304. /*! Gets whether or not the texture is flipped vertically.
  305. @return (bool flipY) Whether or not the texture is flipped along the y axis.
  306. */
  307. ConsoleMethodWithDocs(SpineObject, getFlipY, ConsoleBool, 2, 2, ())
  308. {
  309. return object->getFlipY();
  310. }
  311. //-----------------------------------------------------------------------------
  312. /*! Enables the Jitter special effect
  313. @param JitterX Float - A special effect control parameter.
  314. @param JitterY Float - A special effect control parameter.
  315. @return No return value.
  316. */
  317. ConsoleMethodWithDocs(SpineObject, enableJitter, ConsoleVoid, 4, 4, (float x, float y))
  318. {
  319. // Enable the special effect
  320. object->enableJitter(dAtof(argv[2]), dAtof(argv[3]));
  321. }
  322. //-----------------------------------------------------------------------------
  323. /*! Set the Jitter X control value.
  324. @param X - Float A special effect control parameter.
  325. @return No return value.
  326. */
  327. ConsoleMethodWithDocs(SpineObject, setJitterX, ConsoleVoid, 3, 3, (float x))
  328. {
  329. // Enable the special effect
  330. object->setJitterX(dAtof(argv[2]));
  331. }
  332. //-----------------------------------------------------------------------------
  333. /*! Get the Jitter X control value.
  334. @return The current Jitter effect X control value. If the Jitter effect is not or
  335. has not been enabled, it will return zero.
  336. */
  337. ConsoleMethodWithDocs(SpineObject, getJitterX, ConsoleFloat, 2, 2, ())
  338. {
  339. // Enable the special effect
  340. return object->getJitterX();
  341. }
  342. //-----------------------------------------------------------------------------
  343. /*! Set the Jitter Y control value.
  344. @param Y Float - A special effect control parameter.
  345. @return No return value.
  346. */
  347. ConsoleMethodWithDocs(SpineObject, setJitterY, ConsoleVoid, 3, 3, (float y))
  348. {
  349. // Enable the special effect
  350. object->setJitterY(dAtof(argv[2]));
  351. }
  352. //-----------------------------------------------------------------------------
  353. /*! Get the Jitter Y control value.
  354. @return The current Jitter effect Y control value. If the Jitter effect is not
  355. or has not been enabled, it will return zero.
  356. */
  357. ConsoleMethodWithDocs(SpineObject, getJitterY, ConsoleFloat, 2, 2, ())
  358. {
  359. // Enable the special effect
  360. return object->getJitterY();
  361. }
  362. //-----------------------------------------------------------------------------
  363. /*! Disables the Jitter special effect.
  364. @return No return value.
  365. */
  366. ConsoleMethodWithDocs(SpineObject, disableJitter, ConsoleVoid, 2, 2, ())
  367. {
  368. return object->disableJitter();
  369. }
  370. //-----------------------------------------------------------------------------
  371. /*! Enables the Swirl special effect
  372. @param Radius Float - In degrees. A special effect control parameter.
  373. @return No return value.
  374. */
  375. ConsoleMethodWithDocs(SpineObject, enableSwirl, ConsoleVoid, 3, 3, (float radius))
  376. {
  377. // Enable the special effect
  378. object->enableSwirl(dAtof(argv[2]));
  379. }
  380. //-----------------------------------------------------------------------------
  381. /*! Set the Swirl X control value.
  382. @param X Float - A special effect control parameter.
  383. @return No return value.
  384. */
  385. ConsoleMethodWithDocs(SpineObject, setSwirlX, ConsoleVoid, 3, 3, (float x))
  386. {
  387. // Enable the special effect
  388. object->setSwirlX(dAtof(argv[2]));
  389. }
  390. //-----------------------------------------------------------------------------
  391. /*! Get the Swirl X control value.
  392. @return The current Swirl effect X control value. If the Swirl effect is not
  393. or has not been enabled, it will return zero.
  394. */
  395. ConsoleMethodWithDocs(SpineObject, getSwirlX, ConsoleFloat, 2, 2, ())
  396. {
  397. // Enable the special effect
  398. return object->getSwirlX();
  399. }
  400. //-----------------------------------------------------------------------------
  401. /*! Set the Swirl Y control value.
  402. @param Y Float - A special effect control parameter.
  403. @return No return value.
  404. */
  405. ConsoleMethodWithDocs(SpineObject, setSwirlY, ConsoleVoid, 3, 3, (float y))
  406. {
  407. // Enable the special effect
  408. object->setSwirlY(dAtof(argv[2]));
  409. }
  410. //-----------------------------------------------------------------------------
  411. /*! Get the Swirl Y control value.
  412. @return The current Swirl effect Y control value. If the Swirl effect is not
  413. or has not been enabled, it will return zero.
  414. */
  415. ConsoleMethodWithDocs(SpineObject, getSwirlY, ConsoleFloat, 2, 2, ())
  416. {
  417. // Enable the special effect
  418. return object->getSwirlY();
  419. }
  420. //-----------------------------------------------------------------------------
  421. /*! Set the Swirl Radius control value.
  422. @param Radius Float - A special effect control parameter.
  423. @return No return value.
  424. */
  425. ConsoleMethodWithDocs(SpineObject, setSwirlRadius, ConsoleVoid, 3, 3, (float radius))
  426. {
  427. // Enable the special effect
  428. object->setSwirlRadius(dAtof(argv[2]));
  429. }
  430. //-----------------------------------------------------------------------------
  431. /*! Get the Swirl Radius control value.
  432. @return The current Swirl effect Radius control value. If the Swirl effect is not
  433. or has not been enabled, it will return zero.
  434. */
  435. ConsoleMethodWithDocs(SpineObject, getSwirlRadius, ConsoleFloat, 2, 2, ())
  436. {
  437. // Enable the special effect
  438. return object->getSwirlRadius();
  439. }
  440. //-----------------------------------------------------------------------------
  441. /*! Set the Swirl Angle control value.
  442. @param Angle Float - In degrees. A special effect control parameter.
  443. @return No return value.
  444. */
  445. ConsoleMethodWithDocs(SpineObject, setSwirlAngle, ConsoleVoid, 3, 3, (float radius))
  446. {
  447. // Enable the special effect
  448. object->setSwirlAngle(dAtof(argv[2]));
  449. }
  450. //-----------------------------------------------------------------------------
  451. /*! Get the Swirl Angle control value.
  452. @return The current Swirl effect Angle control value. If the Swirl effect is not
  453. or has not been enabled, it will return zero.
  454. */
  455. ConsoleMethodWithDocs(SpineObject, getSwirlAngle, ConsoleFloat, 2, 2, ())
  456. {
  457. // Enable the special effect
  458. return object->getSwirlAngle();
  459. }
  460. //-----------------------------------------------------------------------------
  461. /*! Disables the Swirl special effect.
  462. @return No return value.
  463. */
  464. ConsoleMethodWithDocs(SpineObject, disableSwirl, ConsoleVoid, 2, 2, ())
  465. {
  466. return object->disableSwirl();
  467. }
  468. //-----------------------------------------------------------------------------
  469. /*! Enables animation event callbacks.
  470. After calling this method, your SpineObject instance will begin to receive animation lifecycle callbacks.
  471. This includes events defined within the animation when it was created. Those embedded events will arrive
  472. in the 'onAnimationEvent' callback, where '%eventName' will indicate which particular event occurred.
  473. @note The onAnimationEvent callback comes with a large number of arguments. These correspond in large part to
  474. the attributes that can be defined for the event inside Spine's animation editor. It is safe to ignore
  475. them if not needed.
  476. The following code block shows every available event callback method. It is okay to define handlers for only
  477. those events of interest, though enabling callbacks and not defining any would just be a waste. More likely
  478. would be to remove the last callback at some future time and forget to disable them.
  479. @code
  480. function SpineObject::onAnimationStart(%this, %animationName, %animationTrack){
  481. echo("SpineObject received onAnimationStart: "@%animationName);
  482. }
  483. function SpineObject::onAnimationInterrupt(%this, %animationName, %animationTrack){
  484. echo("SpineObject received onAnimationInterrupt: "@%animationName);
  485. }
  486. function SpineObject::onAnimationEnd(%this, %animationName, %animationTrack){
  487. echo("SpineObject received onAnimationEnd: "@%animationName);
  488. }
  489. function SpineObject::onAnimationComplete(%this, %animationName, %animationTrack){
  490. echo("SpineObject received onAnimationComplete: "@%animationName);
  491. }
  492. function SpineObject::onAnimationDispose(%this, %animationName, %animationTrack){
  493. echo("SpineObject received onAnimationDispose: "@%animationName);
  494. }
  495. function SpineObject::onAnimationEvent(%this, %animationName, %animationTrack, %eventName, %intArg, %floatArg, %stringArg, %time, %volume, %balance){
  496. echo("SpineObject received onAnimationEvent:" SPC %animationName SPC %eventName);
  497. if(%eventName $= "footstep"){
  498. alxPlay("GameAssets:KnightFootstep");
  499. }
  500. }
  501. @endcode
  502. @return No return value.
  503. */
  504. ConsoleMethodWithDocs(SpineObject, enableAnimationEventCallbacks, ConsoleVoid, 2, 2, ())
  505. {
  506. object->enableEventCallbacks();
  507. }
  508. //-----------------------------------------------------------------------------
  509. /*! Disables animation event callbacks.
  510. @return No return value.
  511. */
  512. ConsoleMethodWithDocs(SpineObject, disableAnimationEventCallbacks, ConsoleVoid, 2, 2, ())
  513. {
  514. object->disableEventCallbacks();
  515. }
  516. //-----------------------------------------------------------------------------
  517. /*! Retrieve a collision proxy object. This is a scene object that wraps a collsion box centered on
  518. a spine attachment. Since it's a SceneObject, it can then be manipulated/used for collision
  519. processing in onCollision etc... This first checks if the attachment requested already has a proxy
  520. and returns that if so. If not, a new proxy is created and returned.
  521. @note
  522. The collision objects never have any velocity. They are continually positioned (warped) to match
  523. the location of the attachment they were created on. This means that they are only useful as
  524. sensors. Even if they are not explicitly set to be sensors, since they have no velocity, they
  525. don't trigger an impulse or other response.
  526. @note
  527. The generated collision proxy is assigned to the same group and layer as the parent spine object.
  528. In addition, its collision mask is configured to disable collisions with all other collision boxes
  529. in that same group. The intent is to prevent collisions between attachements on the same spine
  530. object. Therefore, for different spine objects to collide, they should be assigned to different
  531. scene groups. However, if needed, the settings on the returned proxy may be changed by making the
  532. appropriate calls.
  533. @param AttachmentName String - The spine attachment name that the new proxy should wrap.
  534. @param SlotName String - The slot name that the new proxy should wrap. The slot and attachment
  535. names form a compound key. Both are required to identify the attachment to get a collision
  536. box for.
  537. @param SkinName String Optional - The skin in which to search for the specified attachment name.
  538. If given, then only that skin will be searched for the attachment, and creation will fail if it is not
  539. found. If this parameter is not given (or is set to "default"), then the current skin will be searched
  540. first and if not found, the default skin will be searched. Use "default" if you want the default
  541. behavior while needing to define further optional parameters.
  542. @param SizerWidth Float Optional - A factor that can be used to arbitrarily shrink or grow the generated
  543. box's width. The box remains centered on the attachment.
  544. @param SizerHeight Float Optional - A factor that can be used to arbitrarily shrink or grow the generated
  545. box's height.
  546. @param ObjectName String Optional - Used to set the name of the object returned to the caller.
  547. @return The requested SpineCollisionProxy object, or nothing if creation failed.
  548. */
  549. ConsoleMethodWithDocs(SpineObject, getCollisionProxy, ConsoleString, 4, 8, (char *attachmentName, char *slotName, [char *skinName, float sizerWidth, float sizerHeight, char *objectName]))
  550. {
  551. const char* skinName = argc >= 5 ? argv[4] : "default";
  552. const F32 sizerWidth = argc >= 6 ? dAtof(argv[5]) : 1.0f;
  553. const F32 sizerHeight = argc >= 7 ? dAtof(argv[6]) : 1.0f;
  554. const char* objectName = argc >= 8 ? argv[7] : NULL;
  555. // Get the collision proxy for the requested spine attachment.
  556. const SceneObject* pProxy = object->getCollisionProxy(argv[2], argv[3], skinName, sizerWidth, sizerHeight, objectName);
  557. return pProxy ? pProxy->getIdString() : StringTable->EmptyString;
  558. }
  559. //-----------------------------------------------------------------------------
  560. /*! Delete the given collision proxy.
  561. Proxies will be deleted automatically at cleanup. However, this can be used
  562. to delete one sooner.
  563. @param proxy SpineCollisionProxy - The proxy to delete.
  564. @return bool - True if the object was deleted, false otherwise.
  565. */
  566. ConsoleMethodWithDocs(SpineObject, deleteCollisionProxy, ConsoleBool, 3, 3, (SpineCollsionProxy proxy))
  567. {
  568. // Enable the special effect
  569. return object->deleteCollisionProxy(argv[2]);
  570. }
  571. ConsoleMethodGroupEndWithDocs(SpineObject)