Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Be sure to copy this Script ALWAYS when you copy one of the costum scripts.
- # Otherwise you can encounter "undefined method" errors, because I created
- # these Methods to make a lot of things more simple. It won't have any side
- # effects to copy this script, except getting your copied script to work.
- # Just a quick way to bypass repeating these lines.
- def pbShowAnimation(sprite)
- @sprites["#{sprite}"].setBitmap("Graphics/Pictures/Universal/#{sprite}2")
- pbWait(10)
- @sprites["#{sprite}"].setBitmap("Graphics/Pictures/Universal/#{sprite}")
- pbWait(5)
- end
- # Returning the current Time in this format: M/D/Y at HH:MM
- def retTimeFormatOne
- time=_ISPRINTF("{1:02d}:{2:02d}",Time.now.hour,Time.now.min)
- return ("#{pbGetTimeNow.mon}/#{pbGetTimeNow.day}/#{pbGetTimeNow.year} at #{time}")
- end
- =begin
- # draws the BW2 Cursor Sprite.
- # NOTE: changing the graphic for the Cursor Sprite is very easy now.
- # feel free to change the width/height of the sprites,graphic etc.
- # Just make sure, that every corner of the cursor is at the corner
- # of the sprite.
- def drawBW2Cursor(x,y,width,height)
- disposeBW2Cursor if @cursor_1
- @frame=0
- @shown=0 if @shown==nil;@shown+=1 if !(@shown==2)
- @cursor_1=Sprite.new
- @cursor_1.z=99999
- @cursor_1.bitmap=Bitmap.new("Graphics/Pictures/Universal/select")
- @cursor_2=Sprite.new
- @cursor_2.z=99999
- @cursor_2.bitmap=Bitmap.new("Graphics/Pictures/Universal/select")
- @cursor_3=Sprite.new
- @cursor_3.z=99999
- @cursor_3.bitmap=Bitmap.new("Graphics/Pictures/Universal/select")
- @cursor_4=Sprite.new
- @cursor_4.z=99999
- @cursor_4.bitmap=Bitmap.new("Graphics/Pictures/Universal/select")
- sprite_width_cut=@cursor_1.bitmap.width/2
- sprite_height_cut=@cursor_1.bitmap.height/2
- # x coordinate.
- @cursor_1.x =x
- @cursor_2.x =x
- @cursor_3.x =x+width
- @cursor_4.x =x+width
- # y coordinate.
- @cursor_1.y =y
- @cursor_2.y =y+height
- @cursor_3.y =y
- @cursor_4.y =y+height
- # width.
- @cursor_1.src_rect.width=sprite_width_cut
- @cursor_2.src_rect.width=sprite_width_cut
- @cursor_3.src_rect.width=sprite_width_cut
- @cursor_3.src_rect.x+=sprite_width_cut
- @cursor_4.src_rect.width=sprite_width_cut
- @cursor_4.src_rect.x+=sprite_width_cut
- # height.
- @cursor_1.src_rect.height=sprite_height_cut
- @cursor_2.src_rect.height=sprite_height_cut
- @cursor_2.src_rect.y+=sprite_height_cut
- @cursor_3.src_rect.height=sprite_height_cut
- @cursor_4.src_rect.height=sprite_height_cut
- @cursor_4.src_rect.y+=sprite_height_cut
- end
- # Animates the BW2 Cursor Sprite.
- def animateBW2Cursor(width_distance,height_distance,duration)
- @frame+=1
- if @frame<=(duration/2)
- @cursor_1.x-=width_distance
- @cursor_1.y-=height_distance
- @cursor_2.x-=width_distance
- @cursor_2.y+=height_distance
- @cursor_3.x+=width_distance
- @cursor_3.y-=height_distance
- @cursor_4.x+=width_distance
- @cursor_4.y+=height_distance
- elsif @frame>(duration/2)
- @cursor_1.x+=width_distance
- @cursor_1.y+=height_distance
- @cursor_2.x+=width_distance
- @cursor_2.y-=height_distance
- @cursor_3.x-=width_distance
- @cursor_3.y+=height_distance
- @cursor_4.x-=width_distance
- @cursor_4.y-=height_distance
- end
- @frame=0 if @frame>=duration
- end
- # Disposes the BW2 Cursor Sprite.
- def disposeBW2Cursor
- return if !@cursor_1
- @cursor_1.dispose
- @cursor_2.dispose
- @cursor_3.dispose
- @cursor_4.dispose
- end
- # Wait and Update Method (Used the most for
- def WaitAndUpdate(sprite,path)
- @sprites["#{sprite}"].setBitmap("#{path}2")
- 10.times do
- Graphics.update
- Input.update
- pbWait(1)
- end
- @sprites["#{sprite}"].setBitmap("#{path}")
- 5.times do
- Graphics.updatevv
- Input.update
- pbWait(1)
- end
- end
- # Positions the Pokémon Sprite into the middle.
- def pbPositionBW2Sprite(sprite,x,y)
- if sprite.bitmap && !sprite.bitmap.disposed?
- sprite.x=x-(sprite.bitmap.width/3)
- sprite.y=y-(sprite.bitmap.height/3)
- else
- sprite.x=x
- sprite.y=y
- end
- end
- =end
- # class which was being made to draw the cursor sprite easily and in a good
- # way. thanks Luka S.J for it!
- class UniversalCursor
- # the filepath to the full cursor sprite
- FILE = "Graphics/Pictures/Universal/select"
- # the border size around the target object by which the cursor sprite will
- # be increased so that it does not overlap the target object
- BORDER = 16 # 8 pixels on each side (to account for animation too)
- def initialize(viewport)
- @viewport = viewport
- @sprite = Sprite.new(@viewport)
- @cursor = BitmapCache.load_bitmap(FILE)
- @frame = 0
- @offset = BORDER/2
- end
- def setTo(object)
- # ways to create the cursor bitmap when object is a sprite
- if object.is_a?(Sprite)
- if object.bitmap
- @sprite.bitmap = Bitmap.new(object.bitmap.width+BORDER,object.bitmap.height+BORDER)
- @sprite.ox = @sprite.bitmap.width/2
- @sprite.oy = @sprite.bitmap.height/2
- @sprite.x = object.x + object.bitmap.width/2
- @sprite.y = object.y + object.bitmap.height/2
- @sprite.z=object.z+1
- end
- # ways to create the cursor bitmap when object is a rect
- elsif object.is_a?(Rect)
- @sprite.bitmap = Bitmap.new(object.width+BORDER,object.height+BORDER)
- @sprite.ox = @sprite.bitmap.width/2
- @sprite.oy = @sprite.bitmap.height/2
- @sprite.x = object.x + object.width/2
- @sprite.y = object.y + object.height/2
- end
- self.draw
- end
- def draw
- return if !@sprite.bitmap
- @sprite.bitmap.clear
- # top left corner
- @sprite.bitmap.blt(0,0,@cursor,Rect.new(@offset,@offset,@cursor.width/2,@cursor.height/2))
- # top right corner
- @sprite.bitmap.blt(@sprite.bitmap.width-@cursor.width/2-@offset,@offset,@cursor,Rect.new(@cursor.width/2,0,@cursor.width/2,@cursor.height/2))
- # bottom left corner
- @sprite.bitmap.blt(@offset,@sprite.bitmap.height-@cursor.height/2-@offset,@cursor,Rect.new(0,@cursor.height/2,@cursor.width/2,@cursor.height/2))
- # bottom right corner
- @sprite.bitmap.blt(@sprite.bitmap.width-@cursor.width/2-@offset,@sprite.bitmap.height-@cursor.height/2-@offset,@cursor,Rect.new(@cursor.width/2,@cursor.height/2,@cursor.width/2,@cursor.height/2))
- end
- def animate
- return if !@sprite.bitmap
- @frame+=1
- if @frame > 4
- @offset = (@offset > 0) ? 0 : BORDER/2
- self.draw
- @frame = 0
- end
- end
- def dispose
- return if @sprite.disposed?
- @sprite.dispose
- end
- end
- # class which was made to bypass confusion with the bitmap wrappers and
- # to simply use them as sprites. thanks Luka S.J for it!
- class AnimatedSpriteWrapper < Sprite
- def setBitmap(path,scale=1)
- @bitmap = AnimatedBitmapWrapper.new(path,scale)
- self.bitmap = @bitmap.bitmap.clone
- end
- def play
- @bitmap.play
- self.bitmap = @bitmap.bitmap.clone
- end
- def finished?; return @bitmap.finished?; end
- def animatedBitmap; return @bitmap; end
- def update
- @bitmap.update
- self.bitmap = @bitmap.bitmap.clone
- end
- end
- # Method for automatically starting the animated stuff.
- def startTransition(path)
- sprite=AnimatedSpriteWrapper.new
- sprite.setBitmap(path)
- loop do
- sprite.play
- break if sprite.finished?
- pbWait(1)
- end
- sprite.dispose
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement