nio_kasgami

ExtendedSprite

Nov 3rd, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*:
  2. //==============================================================================
  3. // ■ Nio Kasgami MV Engine - "ExSprite"
  4. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  5.   @plugindesc Utility Plugin who extend the Current sprite classes for being
  6.   more "Ace-like" with in same time conserve all the the MV option.
  7.   @author Nio Kasgami.
  8.   @Data : 2015/11/03
  9.   @Version : 2.0.0
  10.   @Require : NA
  11. //==============================================================================
  12.  
  13. //==============================================================================
  14. // History
  15. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. // 2015/11/03 - Begin and finish the plugin.
  17. // 2015/11/04 - updated for being internal with the default one
  18. //==============================================================================
  19.  
  20. //==============================================================================
  21. // Introduction
  22. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  23. // Are you sometime disapointed some cool Ace feature disapeared in MV?
  24. // this plugin have for meaning to extend the defaults classes.
  25. //==============================================================================
  26.  
  27.  
  28. //==============================================================================
  29. // Plugin Parameter
  30. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  31. // this section handle the plugin parameter. Please do not edit unless you
  32. // want to add extra plugin command.
  33. //------------------------------------------------------------------------------
  34.    * it's a base so this not handle any param commands
  35. //==============================================================================
  36.  
  37. //==============================================================================
  38. // Help File
  39. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  40. // This section serve for input the help file in the engine don't touch this
  41. // unless you want to input more information
  42. //------------------------------------------------------------------------------
  43.    * @help
  44.    * This Sprite plugin extend the current one sprite  classes.
  45.    * For use it, just call this.sprite = new Sprite(); when you initialize a
  46.    * sprite.
  47.    *
  48.    * the new methods
  49.    *  - this.sprite.mirror(hori,verti);
  50.    *  will flip the picture just use true or false for flip picture
  51.    *
  52.    *  - this.sprite.set_origin(x,y);
  53.    *  will set the anchor to the said point. don't forget it's a number of
  54.    *  0 to 1.
  55. */
  56.  
  57. (function() {
  58.     var parameter =  PluginManager.parameters('ExtendedSprite');
  59. })();
  60.  
  61. //==============================================================================
  62. // ■ ExSprite
  63. //------------------------------------------------------------------------------
  64. // Extended version of Sprite for add more "Ace-like" options.
  65. // Call it by using this.varname = new Sprite();
  66. //==============================================================================
  67.  
  68. //----------------------------------------------------------------------------
  69. // ○ new function: mirror
  70. //----------------------------------------------------------------------------
  71. // * This function serve for flip the picture from horizontal and vertical.
  72. // * Just use sprite.mirror(true or false,true or false); and it's will flip
  73. // * the picture. Though be sure to fix the anchor if it's really needed.
  74. //
  75.  Sprite.prototype.mirror = function(hori,verti) {
  76.     if(hori) {
  77.         this.scale.x = -1;
  78.     }else{
  79.         this.scale.x = 1;
  80.     }
  81.     if(verti){
  82.         this.scale.y = -1;
  83.     }else{
  84.         this.scale.y = 1;
  85.     }
  86.  };
  87.  
  88. //----------------------------------------------------------------------------
  89. // ○ new function: mirror
  90. //----------------------------------------------------------------------------
  91. // * This function serve for set anchor in a more lazy ways or Ace way.
  92. // * Totally just a extra code for convenience.
  93. // * call it like this sprite.set_origin(x,y);
  94. //
  95.  Sprite.prototype.set_origin = function(x,y) {
  96.     this.anchor.x = x;
  97.     this.anchor.y = y;
  98.  };
  99. //===============================================================================
  100. // => END : ExSprite
  101. //===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment