Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Sprite
- def bmp(arg1, arg2 = nil)
- if arg2
- arg1 = Graphics.width if arg1 == -1
- arg2 = Graphics.height if arg2 == -1
- self.bitmap = Bitmap.new(arg1, arg2)
- elsif arg1.is_a?(String)
- self.bitmap = BitmapCache.load_bitmap(arg1)
- end
- end
- def xyz=(value)
- self.x = value[0] || 0
- self.y = value[1] || 0
- self.z = value[2] || 0
- end
- def resetBitmap(font = "System")
- self.bitmap.clear if self.bitmap
- self.bmp(-1,-1)
- eval("pbSet#{font}Font(self.bitmap)")
- end
- end
- Example:
- mySprite = Sprite.new(@viewport) # Create a Sprite object
- mySprite.bmp(-1,-1) # Assign an empty bitmap equal to the screen width and height to the sprite
- mySprite.xyz = [100, 33] # Set x to 100 and y to 33. Z stays where it was; zero in this case.
- mySprite.xyz = [82,0,9] # Set x to 82, set y to 0, set z to 9.
- 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