05-07-2020, 05:40 AM
(This post was last modified: 05-07-2020, 11:55 PM by kyonides.
Edit Reason: Ruby 2.7
)
A Revisited ToggleButtonSprite Class Has Arrived!
![[Image: hiddenchest11.jpg]](https://i.postimg.cc/pXD8xjq9/hiddenchest11.jpg)
I'm sorry, you can't escape anymore!
![Shocked Shocked](https://www.save-point.org/images/smilies/ejlol/shocked.gif)
![[Image: hiddenchest11.jpg]](https://i.postimg.cc/pXD8xjq9/hiddenchest11.jpg)
I'm sorry, you can't escape anymore!
![Confused Confused](https://www.save-point.org/images/smilies/ejlol/confused.gif)
Now the hidden ToggleButtonSprite class allows you to use a bitmap to show the player what's on focus right now!
![Grinning Grinning](https://www.save-point.org/images/smilies/ejlol/grin.gif)
I hope this improvement makes it easy to notice where the hell you are at any given time.
![Laughing Laughing](https://www.save-point.org/images/smilies/ejlol/laughing.gif)
By the way, it runs on Ruby 2.7!
![Shocked Shocked](https://www.save-point.org/images/smilies/ejlol/shocked.gif)
In my previous post I forgot to mention I had also included the window padding option in my engine. You see, I had only talked about it on the What's up, RMers? thread
Here is the test script I have been using lately.
Code:
module ButtonData
TITLE = "Scene Settings"
BACKDROP = 'recycle texture'
ICONS = %w{toggle1 toggle2 toggle3 toggle4}
LABELS = ['Find Treasures', 'Kick Asses', 'Play Minigames',
'Contract Covid-19', 'Hug Corona-chan', 'Escape']
end
class ToggleButtons
def initialize(pos, states)
@index = pos
@timer = 0
@buttons = []
@labels = []
@total = ButtonData::LABELS.size
@total.times do |n|
cy = 44 + n * 32
sprite = ToggleButtonSprite.new
sprite.set_xy(8, cy)
sprite.frame = RPG::Cache.icon(ButtonData::ICONS[0])
sprite.bitmap_on = RPG::Cache.icon(ButtonData::ICONS[1])
sprite.bitmap_off = RPG::Cache.icon(ButtonData::ICONS[2])
sprite.button = RPG::Cache.icon(ButtonData::ICONS[3])
sprite.state = states[n]
@buttons << sprite
sprite = Sprite.new
sprite.set_xy(36, cy)
sprite.bitmap = bit = Bitmap.new(160, 28)
bit.draw_text(0, 0, bit.width, bit.height, ButtonData::LABELS[n])
@labels << sprite
end
@buttons[0].focus = true
@buttons[5].block = true
end
def change_focus(pos)
@buttons[@index].focus = false
@buttons[pos].focus = true
@index = pos
end
def update
@buttons.each{|button| button.update }
return @timer -= 1 if @timer > 0
if Input.left_click?
pos = 0
@buttons.each do |button|
unless button.mouse_above?
pos += 1
next
end
if button.block
Audio.play_buzzer
change_focus(pos)
return @timer = Graphics.frame_rate / 3
end
Audio.play_ok
change_focus(pos) if @index != pos
button.state = !button.state
@timer = Graphics.frame_rate / 3
return
end
return
elsif Input.trigger?(Input::UP)
Audio.play_cursor
@buttons[@index].focus = false
@index = (@index - 1) % @total
@buttons[@index].focus = true
return
elsif Input.trigger?(Input::DOWN)
Audio.play_cursor
@buttons[@index].focus = false
@index = (@index + 1) % @total
@buttons[@index].focus = true
end
end
def dispose
(@buttons + @labels).each{|b| b.dispose }
end
def states() @buttons.map(&:state) end
end
class MenuScene
def main
@bg = Sprite.new
@bg.bitmap = RPG::Cache.title(ButtonData::BACKDROP)
@title = Sprite.new
@title.set_xy(Graphics.width / 2 - 120, 8)
@title.bitmap = bit = Bitmap.new(240, 32)
bit.draw_text(0, 0, 240, 32, ButtonData::TITLE, 1)
states = [true, false, true, false, true, false]
@buttonset = ToggleButtons.new(0, states)
states.clear
Graphics.transition
main_loop while $scene == self
Graphics.freeze
@buttonset.dispose
@title.dispose
@bg.dispose
end
def main_loop
Graphics.update
Input.update
update
end
def update
@buttonset.update
if Input.trigger?(Input::B)
Audio.play_cancel
@buttonset.states
$scene = Scene_Title.new
return
elsif Input.trigger?(Input::KeyP)
Audio.play_ok
Graphics.save_screenshot
return
end
end
end
My Final Message is...
![Confused Confused](https://www.save-point.org/images/smilies/ejlol/confused.gif)
There is no end! ![Laughing + Tongue sticking out Laughing + Tongue sticking out](https://www.save-point.org/images/smilies/ejlol/laughingtongue.gif)
![Laughing + Tongue sticking out Laughing + Tongue sticking out](https://www.save-point.org/images/smilies/ejlol/laughingtongue.gif)
Unless
catches you off guard.
![Corona-Chan Corona-Chan](https://www.save-point.org/images/smilies/ejlol/corona.gif)
![Sad Sad](https://www.save-point.org/images/smilies/ejlol/sad.gif)
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
![[Image: SP1-Scripter.png]](https://www.save-point.org/images/userbars/SP1-Scripter.png)
![[Image: SP1-Writer.png]](https://www.save-point.org/images/userbars/SP1-Writer.png)
![[Image: SP1-Poet.png]](https://www.save-point.org/images/userbars/SP1-Poet.png)
![[Image: SP1-PixelArtist.png]](https://www.save-point.org/images/userbars/SP1-PixelArtist.png)
![[Image: SP1-Reporter.png]](https://i.postimg.cc/GmxWbHyL/SP1-Reporter.png)
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!![Laughing + Tongue sticking out Laughing + Tongue sticking out](https://www.save-point.org/images/smilies/ejlol/laughingtongue.gif)
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
![[Image: SP1-Scripter.png]](https://www.save-point.org/images/userbars/SP1-Scripter.png)
![[Image: SP1-Writer.png]](https://www.save-point.org/images/userbars/SP1-Writer.png)
![[Image: SP1-Poet.png]](https://www.save-point.org/images/userbars/SP1-Poet.png)
![[Image: SP1-PixelArtist.png]](https://www.save-point.org/images/userbars/SP1-PixelArtist.png)
![[Image: SP1-Reporter.png]](https://i.postimg.cc/GmxWbHyL/SP1-Reporter.png)
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
![Laughing + Tongue sticking out Laughing + Tongue sticking out](https://www.save-point.org/images/smilies/ejlol/laughingtongue.gif)
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE