The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Zylos on March 28, 2012, 03:11:58 AM

Title: A question about VXA opacity... [Resolved]
Post by: Zylos on March 28, 2012, 03:11:58 AM
One of the things I want to try to do with VXA is set up a strange feature that makes a ghost enemy become more opaque the closer event gets to the player, thus making it somewhat invisible from a distance. The math behind it is simple, just good old geometry's distance formula, so it's very easy to determine the distance between the player and the enemy in question. What is NOT easy is figuring out how to manually write in the enemy's new opacity via scripting. It can be done via eventing, but it would take a LOT of conditional branches to make the process look smooth, when a single "$game_map.events[n].opacity = " would work a whole lot simpler and smoother if such a thing existed.

So what I want to ask is simple: What's the bloody coding for an event's opacity? x_x
Title: Re: A question about VXA opacity...
Post by: pacdiggity on March 28, 2012, 07:02:20 AM
I would help you if I wasn't against you in GIAW :mad:
Spoiler for:
:V
Truth is, in Game_CharacterBase @opacity is set to an attr_reader, which means that it can't be overwritten from outside classes. A simple fix for this would be sticking this in the script editor:
Code: [Select]
class Game_CharacterBase
  attr_accessor :opacity
end
Then you could use $game_map.events[n].opacity = x
I think.
Title: Re: A question about VXA opacity...
Post by: Zylos on March 28, 2012, 04:24:15 PM
A nice idea, but the variable already exists in $game_characterbase when I checked. Just can't seem to access it for some reason, even when I tried $game_player.opacity to mess with the player's transparency.
Title: Re: A question about VXA opacity...
Post by: modern algebra on March 28, 2012, 09:01:33 PM
Yeah, that's what he's saying. The @opacity instance variable exists, but there is no opacity= method which would permit you to change it from outside the class. If you do:

Code: [Select]
class Game_CharacterBase
  attr_writer :opacity
end

then what you will do is create the opacity= method, permitting you to do that which you desire to do.
Title: Re: A question about VXA opacity...
Post by: Zylos on March 29, 2012, 01:32:29 AM
There we go, that works perfectly! Allowed me to put in a formula easily for growing more opaque the closer the event in question is to the player.
Title: Re: A question about VXA opacity... [Resolved]
Post by: pacdiggity on March 29, 2012, 02:35:20 AM
Did you even read my post? It's pretty much exactly the same thing. .-.