Author Topic: "Opening" windows?  (Read 1663 times)

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5135
  • LV: 198
  • Gender: Female
  • Wants to write a compiler for fun
    • View Profile
"Opening" windows?
« on: April 10, 2009, 04:53:28 AM »
how do you recreate the effect of "opening" a window ie. how a scroll would open the window starts a a thin strip and then "opens" the top and bottom of the box moving up and down respectively till the window is its full height.

I considered the idea of having the window start off at 32 pixels high and then adding to the windows height and changing the x value till it was right but then I would have to stop it from drawing the inside of the window till it was all the way open. I don't think it would work very well.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Fantasist

  • Lexima Warrior
  • *******
  • Posts: 2223
  • LV: 146
  • Gender: Male
    • View Profile
    • Blog
Re: "Opening" windows?
« Reply #1 on: April 10, 2009, 09:06:36 AM »
Just kcontrol when self.contents is created. Make the contents only after the window is opened.
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)

The best of freeware reviews: Gizmo's Freeware Reviews



Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5135
  • LV: 198
  • Gender: Female
  • Wants to write a compiler for fun
    • View Profile
Re: "Opening" windows?
« Reply #2 on: April 11, 2009, 12:11:58 AM »
but it will look weird opening an empty window and then creating the contents bitmap. think about it its an empty window, and then suddenly there is text. wouldn't that look a bit odd?
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Landith

  • Astral Trancist
  • *****
  • Posts: 947
  • LV: 59
  • Gender: Male
    • View Profile
Re: "Opening" windows?
« Reply #3 on: April 11, 2009, 12:18:54 AM »
Maybe... Play a transition of it sliding down as you open the window..?
Idk if you can do that only for the text though...

Offline fugibo

  • World Conqueror
  • Chaos User
  • ******
  • Posts: 1966
  • LV: 44
    • View Profile
Re: "Opening" windows?
« Reply #4 on: April 11, 2009, 01:17:36 AM »
Have a boolean "animating variable:"
Code: [Select]
def initialize
  @animating = false
  ...
end

Have a fork in the "update" method:
Code: [Select]
def update
  return @animating ? animate : normal_update
end

Have an "animate" method:

Code: [Select]
def animate
  self.y -= 2
  self.width += 4
  if self.y == <desired> && self.width = <desired>
    @animating = false
    finalize
  end
end

Have a "normal_update" method:
Code: [Select]
def normal_update
  (do normal updating stuff)
end

Have a "finalize" method:
Code: [Select]
def finalize
  self.contents = Bitmap.new(<size1>, <size2>)
 
  (do stuff to draw the window)
end

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5135
  • LV: 198
  • Gender: Female
  • Wants to write a compiler for fun
    • View Profile
Re: "Opening" windows?
« Reply #5 on: April 11, 2009, 01:31:02 AM »
thanks WcW

I'll try this out and see how it looks, then report back to tell you if it had the desired effect.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline fugibo

  • World Conqueror
  • Chaos User
  • ******
  • Posts: 1966
  • LV: 44
    • View Profile
Re: "Opening" windows?
« Reply #6 on: April 11, 2009, 01:40:11 AM »
I also spent a few minutes on this:
Code: [Select]
=begin
Window_Animated Template
v 1.00

This is a template for Window Animations that simplifies
the process of having a window animate when it opens or
closes (ex. LoLIV:CP)

To use:

* Subclass Window_Animated
* Implement your initialize method, calling super(x, y, w, h) FIRST
* Now implement an animate_open method, which will do the effect for
opening
* Next, implement an opened? method which will check to see if the
animation is complete (it can check a frame count using
@open_count)
* Now implement a finalize_open method, which will create the bitmap
and such that would normally be done in initialize
* Now, do that all for close (using animate_close, closed?, @close_count,
and finalize_close)
* Now you can implement a normal_update method, which will be you regular
update method
* Optionally you can implement a universal_update method which will be
called whether or not it is opening, closing, or doing nothing. This
makes it easier for you to code -- not redefinition of update required

Note that this has no guarantee of working -- I do not have the real RMXP
on me

-- WcW (no credits require if you use this)
=end

class Window_Animated < Window
def initialize(x = 0, y = 0, w = 1, y = 1)
super(x, y, w, h)

@opening = true
@closing = false

@open_count = 0
@close_count = 0
end

def update_open
@open_count += 1

animate_open if method_defined?(:animate_open)

if method_defined?(:opened?) && opened?
@opening = false
finalize_open if method_defined?(:finalize_open)
@open_count = 0
end
end

def update_close
@close_count += 1

animate_close if method_defined?(:animate_close)

if method_defined?(:closed?) && closed?
@closing = false
finalize_close if method_defined?(:finalize_close)
@close_count = 0
end
end

def update
super()

if @opening
update_open
elsif @closing
update_close
else
normal_update if method_defined?(:normal_update)
end

universal_update if method_defined?(:universal_update)
end
end

You can try that, as it will result in cleaner, easier to maintain code. It automatically handles the hard parts :P

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5135
  • LV: 198
  • Gender: Female
  • Wants to write a compiler for fun
    • View Profile
Re: "Opening" windows?
« Reply #7 on: April 11, 2009, 07:30:29 AM »
 :O.o:
I didn't expect that much help thanks WcW
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline fugibo

  • World Conqueror
  • Chaos User
  • ******
  • Posts: 1966
  • LV: 44
    • View Profile
Re: "Opening" windows?
« Reply #8 on: April 11, 2009, 11:36:16 AM »
NP. I just like doing things in a clean object-oriented way, and the best way is with a good base class. It's only 40 lines of code :P