Advertisement
hikanh

Untitled

Oct 23rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. class Sprite
  2. def bmp(arg1, arg2 = nil)
  3. if arg2
  4. arg1 = Graphics.width if arg1 == -1
  5. arg2 = Graphics.height if arg2 == -1
  6. self.bitmap = Bitmap.new(arg1, arg2)
  7. elsif arg1.is_a?(String)
  8. self.bitmap = BitmapCache.load_bitmap(arg1)
  9. end
  10. end
  11.  
  12. def xyz=(value)
  13. self.x = value[0] || 0
  14. self.y = value[1] || 0
  15. self.z = value[2] || 0
  16. end
  17.  
  18. def resetBitmap(font = "System")
  19. self.bitmap.clear if self.bitmap
  20. self.bmp(-1,-1)
  21. eval("pbSet#{font}Font(self.bitmap)")
  22. end
  23. end
  24.  
  25. Example:
  26. mySprite = Sprite.new(@viewport) # Create a Sprite object
  27. mySprite.bmp(-1,-1) # Assign an empty bitmap equal to the screen width and height to the sprite
  28. mySprite.xyz = [100, 33] # Set x to 100 and y to 33. Z stays where it was; zero in this case.
  29. mySprite.xyz = [82,0,9] # Set x to 82, set y to 0, set z to 9.
  30. mySprite.resetBitmap # Clears any text and any images that were on the bitmap and re-assigns an empty bitmap to the sprite.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement