[RMVX ACE] SHOW WINDOW AND PICTURE WITH SCRIPT

Posts

Pages: 1
Hi, third time trying to post this (didn t realize about the message limit for newcomers), hope it goes through now...

I ve been trying to learn scripting in vx Ace, usually start with creating an event with all the steps necessary to get what I want, then try to recreate as a script (lot of reading about classes but little understanding...maybe not the best way ). So far I made a scriplet to make a window and added a way for it to turn the window on and off. But i m not sure how to add a background image to it. What I did was call Scene base, then define creating window, then input buttons. I then defined window Base and updating. This took me a load of tries and i m not sure if it s a good way (but it works).

When i got it, i noticed i didn t add a way to show a background image. Let s say i want "data_mine.png" in the "pictures" folder to appear on the same pos that the (transparent) text window does. my question is how to do this. I don t think i ll use a script call like

$game_map.screen.pictures[n].show


because i want it to happen at same time. but for this Which class should I call? Where and how should I define it in the scriplet (what order)? I found about

$game_map.screen.pictures[index].show(fName, placement, x, y, xZoom, yZoom, opacity, blend)


but am really not sure about what s the "index", or if it s meant to be used here. Can anyone help? Thank you :)

(sorry for the missing characters, my keyboard s all shot up :( )
If you're working with scripts, it may be a good time to learn how to create sprites! Pictures are the user friendly version of the Sprite class. You can add a sprite to the scene with...

@sprite = Sprite.new

@sprite.bitmap = Cache.picture("picture_name_here")
@sprite.x = x_coordinate
@sprite.y = y_coordinate


Be sure to add a dispose method to properly get rid of the sprite or you'll end up with memory leaks.

def dispose

@sprite.bitmap.dispose
@sprite.dispose
end


Try playing with that, and reference the help file to check out all the things you can do with them.
Hello, infinite. Sorry for the delay in the reply. What can I say other than a big "thank you"? :D it works, though I have to play it straight: I'm not sure I've used sprite.bitmap correctly. Not sure why, maybe some error on my part or an issue with the referenced class I was using. The first part inherits from Scene_Base and the second from Window_Base. It was in this last one I had the problem. I did several tests (not always easy with the little free time I have), but in the end, used create_background.


def create_background
@background_sprite = Sprite.new
@background_sprite.bitmap = Cache.picture ("n")
@background_sprite.x = x_coordinate
@background_sprite.y = y_coordinate
end

def update
super
if Input.trigger?(:A)
@background_sprite.dispose
@@background_sprite.bitmap.dispose
elsif Input.trigger?(:B)
create_background
end
end


The super is there because of the other things going on in the window. So I'm not really sure why I couldn't use the sprite.bitmap directly (or if this code is the same as using it). To be honest again, it was very late and I may just have made a typo somewhere in the code. However, it's working perfectly now.

Thank you once again for your time, explanation and nudging me in the right way :)
Pages: 1