Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Animated Window Skin

Tana

Member

ATO asked me to repost this, and it is my very first script so:

In order to make a windowskin appear animated by cycling through a series of skins:

In Window_Base
Replace all of "def initialize" with:

Code:
def initialize(x, y, width, height)
    super()
    self.windowskin = RPG::Cache.windowskin("Blue_1") #
    self.x = x
    self.y = y
    self.width = width
    self.height = height
    self.z = 100
    self.opacity = 160
    @blink_count = 0 #
    end
Where "Blue_1" is the name of your first skin.
The important parts are the line that defines the name of the first skin, and the line that sets @blink_count = 0

Then replace all of "def update" with:
Code:
def update
    super
   #Animates the Window Skin
    @blink_count = (@blink_count + 1) % 40
    if @blink_count < 10
      self.windowskin = RPG::Cache.windowskin("Blue_1") #name of skin frame 1
    elsif (@blink_count >= 10 and @blink_count < 20)
      self.windowskin = RPG::Cache.windowskin("Blue_2") #skin frame 2
    elsif (@blink_count >= 20 and @blink_count < 30)
      self.windowskin = RPG::Cache.windowskin("Blue_3") #skin frame 3
    else
      self.windowskin = RPG::Cache.windowskin("Blue_4") #skin frame 4
    end
  end

To add or subtract frames from the animation, we change the blinkcount stuff.

Code:
@blink_count = (@blink_count + 1) % 40
The 40 defines how high it counts. I used 4 frames, so 40 in this case. The higher this number, the more skins can be cycled through; or the longer a skin can be held.

Code:
elsif (@blink_count >= 10 and @blink_count < 20)
self.windowskin = RPG::Cache.windowskin("Blue_2")
This means that while its counting, and it's a number between 10-19 it'll display the 2nd skin.
I set the range that each skin is held for a count of 10, but you can make that range longer or shorter.

Basically, that first number, the counting max needs to be divisable by how many skins you're using, and how many frames you want each skin to hold.

Yay!

oh, and a demo now:
http://www.alisachristopher.us/rmxp/WindowSkinTest.exe
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top