RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[resolved]Script for Picture Display?

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 82
We learn by living...
I am baffled right now as to how to get a picture to display with some coordinates as basic as 0x, 0y using the picture equivalent of
Code: [Select]
  Audio.bgm_play("Audio/BGM/043-Positive01.mid", 100, 100)

basically, I'm looking for something to post pictures, instead of playing music. Coordinate options would be a plus.
« Last Edit: January 04, 2011, 04:20:20 AM by shintashi »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, depending on what scene you are in, there may already be the infrastructure to do it (Scene_Map and Scene_Battle)

Otherwise, it's not particularly difficult. Just create a sprite and set the bitmap to the picture you want. Something like:

Code: [Select]
sprite = Sprite.new
sprite.bitmap = RPG::Cache.picture ("filename") # <- Don't need to put the directory path
sprite.x, sprite.y = x, y

I used picture, since I'm assuming that's the directory you are grabbing it from. If not, you just need to modify which method you call from RPG::Cache. You can find a list in the Help file. If you were really opposed to caching it, then you could just use:

Code: [Select]
Bitmap.new (path)
where path is the directory and filename like in your audio example.

You may also need to set the z coordinate, depending again on what scene you are in and whether you need it to appear under or over something.

And of course, if you are already in a window or sprite, you can just use the blt method on the bitmap object, but I'm assuming that you know that and that you are wondering just about how to show a picture on the screen.

***
Rep:
Level 82
We learn by living...
Well, depending on what scene you are in, there may already be the infrastructure to do it (Scene_Map and Scene_Battle)

Otherwise, it's not particularly difficult. Just create a sprite and set the bitmap to the picture you want. Something like:

Code: [Select]
sprite = Sprite.new
sprite.bitmap = RPG::Cache.picture ("filename") # <- Don't need to put the directory path
sprite.x, sprite.y = x, y

I used picture, since I'm assuming that's the directory you are grabbing it from. If not, you just need to modify which method you call from RPG::Cache. You can find a list in the Help file. If you were really opposed to caching it, then you could just use:

Code: [Select]
Bitmap.new (path)
where path is the directory and filename like in your audio example.

You may also need to set the z coordinate, depending again on what scene you are in and whether you need it to appear under or over something.

And of course, if you are already in a window or sprite, you can just use the blt method on the bitmap object, but I'm assuming that you know that and that you are wondering just about how to show a picture on the screen.

I put in sprite.z at 3000, I'm not sure what it's supposed to be, actually, but it showed up. Without the z coordinate the windows covered it completely.

***
Rep:
Level 82
We learn by living...
hmnn.. how do I clear it once it is displayed? like from another menu option.

@window_a1.sprite.bitmap.clear and @window_a1.contents.clear failed me.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, now I'm confused as to where you are putting it. If it is in a window, you should really just be drawing it onto the window's bitmap.

In any case, you'd want to do:

Code: [Select]
sprite.bitmap.dispose
sprite.dispose

if you're using a Sprite. However, if it's inside some other class than it wouldn't by default be accessible outside the class - you'd need to make it publicly accessible.

But like I said, if it's a window, then using the sprite is kind of weird. Not wrong, necessarily - it can certainly be very useful to control a sprite within a window and I've done it on occasion - just peculiar.

But yeah, it sounds as if you are trying to access the sprite from outside of the class you created it in, so just make it publicly accessible or else write a sprite dispose method in the class and call it. I'd need to know more about the infrastructure of the class before I could tell you anything more useful than that though.

***
Rep:
Level 82
We learn by living...
Well, now I'm confused as to where you are putting it. If it is in a window, you should really just be drawing it onto the window's bitmap.

In any case, you'd want to do:

Code: [Select]
sprite.bitmap.dispose
sprite.dispose

if you're using a Sprite. However, if it's inside some other class than it wouldn't by default be accessible outside the class - you'd need to make it publicly accessible.

But like I said, if it's a window, then using the sprite is kind of weird. Not wrong, necessarily - it can certainly be very useful to control a sprite within a window and I've done it on occasion - just peculiar.

But yeah, it sounds as if you are trying to access the sprite from outside of the class you created it in, so just make it publicly accessible or else write a sprite dispose method in the class and call it. I'd need to know more about the infrastructure of the class before I could tell you anything more useful than that though.

It's definitely in a window. I modified the windows from Dubealex's Ruby tutorial, but I'm still uncomfortable with draw and windows script. The images are in the pictures directory. My roomate wants an "Organic Chemist" character class (don't ask) and I need to be able to stick images in her game.

Here's the script:

Code: [Select]
class Scene_Chapter3_menu1

def initialize(menu_index = 0)
   @menu_index = menu_index #Store the cursor position
end 

#--------------------------------------------------------------------------------------------------------

def main
@window_a1=Window_a1.new #Content Window
@window_a1.update(false) #Decide whether to show/hide the content...
@window_a1.x=160
@window_a1.y=0

# stuff goes here
  s1 = "Items"
  s2 = "Infos"
  s3 = "Music A"
  s4 = "Image"
  s5 = "Exit"
  @window_a2 = Window_Command.new(160, [s1,s2,s3,s4,s5]) #160 is width
  @window_a2.y=0 #Set a position for the menu other than 0:0
  @window_a2.height=480 #Force a new height for the menu window
  @window_a2.index = @menu_index
# end stuff
#This is what makes the scene update itself constantly:
Graphics.transition
loop do
Graphics.update
Input.update
update #Call the method DEF UPDATE starting below
if $scene != self
  break
end
end

#Execute when exiting the scene:
Graphics.freeze
@window_a1.dispose
@window_a2.dispose
#@window_a3.dispose #edited out with begins/ends etc.
end

#--------------------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------------------------

def update
 
@window_a2.update #menu

#THIS IS FOR THE OPTION FUNCTIONS:
if Input.trigger?(Input::C) #Do the following if ENTER is pressed...
case @window_a2.index #window_a2 is the menu... index is it's cursor position !
  when 0 #Remember that the cursor position start at 0, because it's an Array !!
    item #item - s1
  when 1
    infos #infos -s2
  when 2
    music_a #Music A - s3
  when 3
    music_b #Music B - s4
  when 4
    exit #Exit - s5
  end 
end

# --- end stuff
if Input.trigger?(Input::B) #Press ESCAPE to exit
  $game_system.se_play($data_system.cancel_se)
  $scene = Scene_Map.new
  $game_map.autoplay #Because we play music in the menu...
end

end
#--------------------------------------------------------------------------------------------------------

#Options Method Start Here:
#actual result of options goes here.
def item #s1, menu_index=0
  $game_system.se_play($data_system.decision_se) #play an SE
  $scene = Scene_Item.new #Syntax to change scene
  end 

def infos #s2, menu_index=1
@window_a1.update(true)
$game_actors[9].str += 10 #works, added by shintashi
end 

def music_a #s3, menu_index=2
  Audio.bgm_play("Audio/BGM/043-Positive01.mid", 100, 100) #Play custom BGM
end

def music_b #s4, menu_index=3
  sprite = Sprite.new
sprite.bitmap = RPG::Cache.picture ("adenosine") # <- Don't need to put the directory path
sprite.z, sprite.x, sprite.y = 120, 160, 0
#  Audio.bgm_play("Audio/BGM/044-Positive02.mid", 100, 100) #Play custom BGM
#@window_a1.contents.clear # added by shintashi
  end

def exit #s5, menu_index=4
  $game_system.se_play($data_system.cancel_se) #play an SE
  $scene = Scene_Map.new #Syntax to change scene
  $game_map.autoplay #Because we play music in the menu...
end
# end actual result of options

#--------------------------------------------------------------------------------------------------------
end #of the Scene !

#===================================================
#  CLASS Window_a1 BEGINS (Content Window)
#===================================================
class Window_a1 < Window_Base

def initialize
super(0, 0, 480,480)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = "Tahoma" 
self.contents.font.size = 20
end

def update(content) #Receive the argument from the menu
if content == false #If false, don't show content
    self.contents.clear
    self.contents.draw_text(0, 0, 120, 32, "No Content...")
  else #else, if true, show it...
    self.contents.clear
    self.contents.draw_text(0, 0, 440, 32, "STAT +10") 
end
end

end
« Last Edit: December 17, 2010, 05:16:20 AM by shintashi »

**
Rep:
Level 84
Know where you've been, to find out where your goi
I have given it ago and just added the required dispose method at the window exit. Aswell as create the instance varibale needed to show the image.

Code: [Select]
class Scene_Chapter3_menu1
 
def initialize(menu_index = 0)
   @menu_index = menu_index #Store the cursor position
end

#--------------------------------------------------------------------------------------------------------

def main
#----Instance Varibale creates a blank sprite-----#
@sprite = Sprite.new
@sprite.z, @sprite.x, @sprite.y = 120, 160, 0
#-------------------------------------------------#
@window_a1=Window_a1.new #Content Window
@window_a1.update(false) #Decide whether to show/hide the content...
@window_a1.x=160
@window_a1.y=0

# stuff goes here
  s1 = "Items"
  s2 = "Infos"
  s3 = "Music A"
  s4 = "Image"
  s5 = "Exit"
  @window_a2 = Window_Command.new(160, [s1,s2,s3,s4,s5]) #160 is width
  @window_a2.y=0 #Set a position for the menu other than 0:0
  @window_a2.height=480 #Force a new height for the menu window
  @window_a2.index = @menu_index
# end stuff
#This is what makes the scene update itself constantly:
Graphics.transition
loop do
Graphics.update
Input.update
update #Call the method DEF UPDATE starting below
if $scene != self
  break
end
end

#Execute when exiting the scene:
Graphics.freeze
@window_a1.dispose
@window_a2.dispose
@sprite.dispose
#@window_a3.dispose #edited out with begins/ends etc.
end

#--------------------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------------------------

def update
 
@window_a2.update #menu

#THIS IS FOR THE OPTION FUNCTIONS:
if Input.trigger?(Input::C) #Do the following if ENTER is pressed...
case @window_a2.index #window_a2 is the menu... index is it's cursor position !
  when 0 #Remember that the cursor position start at 0, because it's an Array !!
    item #item - s1
  when 1
    infos #infos -s2
  when 2
    music_a #Music A - s3
  when 3
    music_b #Music B - s4
  when 4
    exit #Exit - s5
  end
end

# --- end stuff
if Input.trigger?(Input::B) #Press ESCAPE to exit
  $game_system.se_play($data_system.cancel_se)
  $scene = Scene_Map.new
  $game_map.autoplay #Because we play music in the menu...
end

end
#--------------------------------------------------------------------------------------------------------

#Options Method Start Here:
#actual result of options goes here.
def item #s1, menu_index=0
  $game_system.se_play($data_system.decision_se) #play an SE
  $scene = Scene_Item.new #Syntax to change scene
  end

def infos #s2, menu_index=1
@window_a1.update(true)
$game_actors[1].str += 10 #works, added by shintashi
end

def music_a #s3, menu_index=2
  Audio.bgm_play("Audio/BGM/043-Positive01.mid", 100, 100) #Play custom BGM
end

def music_b #s4, menu_index=3
  @sprite.bitmap = RPG::Cache.picture ("w1") # <- Don't need to put the directory path
  #Audio.bgm_play("Audio/BGM/044-Positive02.mid", 100, 100) #Play custom BGM
  #@window_a1.contents.clear # added by shintashi
  end

def exit #s5, menu_index=4
  $game_system.se_play($data_system.cancel_se) #play an SE
  $scene = Scene_Map.new #Syntax to change scene
  $game_map.autoplay #Because we play music in the menu...
end
# end actual result of options

#--------------------------------------------------------------------------------------------------------
end #of the Scene !

#===================================================
#  CLASS Window_a1 BEGINS (Content Window)
#===================================================
class Window_a1 < Window_Base

def initialize
super(0, 0, 480,480)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = "Tahoma"
self.contents.font.size = 20
end

def update(content) #Receive the argument from the menu
if content == false #If false, don't show content
    self.contents.clear
    self.contents.draw_text(0, 0, 120, 32, "No Content...")
  else #else, if true, show it...
    self.contents.clear
    self.contents.draw_text(0, 0, 440, 32, "STAT +10")
end
end

end


Hope that helps

theconqueror
« Last Edit: December 31, 2010, 02:21:47 PM by theconqueror »

***
Rep:
Level 82
We learn by living...
works ^^

i just had to change "w1" back to "adenosine"

thanks much :)