Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Set Player Opacity

Xrazor

Member

Hello,

I already tried many things, but I just don't get it to work properly.
What I try to do is simply setting the opacity of the Player to 0 via
Script, but it just don't work right. The only time it worked the sprite was
disposed about 2-3seconds after I set it to 0 through many invonvenient
code snippts.
I need this for my AKS, because I'm showing an attack animation instead
of the player sprite.
 
Have you tried:

Create a new event, set it to autorun, and use a switch to control it,
then add a Set move route, target is player, then change opacicy to 0.

hope that helps, if you need images then ill post them here.
 

Xrazor

Member

Sorry, but that's not what I'm looking for, I don't want to use a blank graphic neither an event to change the opacity. What I need is a script solution, there must be the possibilty to change the opacity of the player and refresh the grapic in an instant.
 

Xrazor

Member

Legacy, yours won't work because the varibale is not defined,
and if so, it would be the same like that from archerRin and that doesn't work
although you change the attr of opacity to accessor.

What's up with the Scripting Pro's?
 
What you guys do wrong is that you try to set the player's opacity to 0, which makes no sense at all. What you have to do is set the player's sprite's opacity to 0 (remember: player is the instance, it's sprite is the visual representation). So, not having any maker program around, you'd have to look yourself inside Game_Character, where you can write up a method like set_character_opacity(integer) to change it on the fly.

For what you said in your first post (working for two to three seconds), I have not really an idea where that's coming from, because I'm not aware of a default script that sets the player sprite's opacity back to 255 at an interval. So, I figure you misplaced your code, or there's another script interfering with it you didn't share with us.

Either way, if you want a custom attack animation, why don't you just put that into character sets and replace the players regular sprites with the attack sprites? That would be much easier for sprite placement than using battle animations either way...
 
You can try using this script by Punk, I happen to use it as a staple in my library too because its oh so convenient lil' script ;)

=begin
╔══════════════════════════════════════════════════════════════════════════════╗
║ Character Sprite Addons ║
║ Version 1.1 by Punk ║
╟──────────────────────────────────────────────────────────────────────────────╢
╟──────────────────────────────────────────────────────────────────────────────╢
║ ■ Description: ║
║ └─ Adds on additional properties to character sprites which weren't included ║
║ before such as Angle, Tone, Color, Mirror, Zoom_X and Zoom_Y. ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ ■ Features: ║
║ ├─ Gives character sprites additional properties from the Sprite class such ║
║ │ as angle, tone, color, mirror, zoom_x and zoom_y. ║
║ └─ Change the angle, size, color, tone of a character sprite as well as ║
║ flipping it horizontally with script calls. (New to Version 1.1) ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ ■ Customization ║
║ └─ For those who don't like how in the zoom functions, the value 1.0 ║
║ signifies "actual pixel size", I've changed it a bit to make the value ║
║ 100.0 signify actual pixel size. For those who may not like the update, ║
║ you can disable this by jumping to the third line after this long box ║
║ and set CharacterSpriteZoom100 to false. ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ ■ Usage: ║
║ │ ► Tones. ║
║ ├─ How do I change the tone of the player's sprite? ║
║ │ 1. Use Call script event command. ║
║ │ 2. Type this (replace red green blue saturation with values): ║
║ │ $game_player.tone = Tone.new(red, green, blue(, sat)) ║
║ │ return true ║
║ ├─ How do I change the tone of an event's sprite? ║
║ │ 1. Use Call script event command. ║
║ │ 2. Type this (replace id with an event id): ║
║ │ $game_map.events[id].tone = Tone.new(red, green, blue(, sat)) ║
║ │ return true ║
║ ├─ Example usage? I may still be confused. ║
║ │ $game_player.tone = Tone.new(100, 100, 100, 255);return true ║
║ │ $game_player.tone = Tone.new(-64, 0, -64, 0);return true ║
║ │ $game_player.tone = Tone.new(-64, 0, -64);return true ║
║ │ ║
║ │ ► Angles. ║
║ ├─ How do I change the angle of the player's sprite? ║
║ │ 1. Use Call script event command. ║
║ │ 2. Type this (replace angle with a value): ║
║ │ $game_player.angle = value ║
║ ├─ How do I change the angle of an event's sprite? ║
║ │ 1. Use Call script event command. ║
║ │ 2. Type this (replace angle with a value, id with an event id): ║
║ │ $game_map.events[id].angle = value ║
║ │ ║
║ │ ► Colors. ║
║ ├─ How do I change the color of the player's sprite? ║
║ │ 1. Use Call script event command. ║
║ │ 2. Type this (replace red green blue alpha with values): ║
║ │ $game_player.color = Color.new(red, green, blue(, alpha)) ║
║ │ return true ║
║ ├─ How do I change the angle of an event's sprite? ║
║ │ 1. Use Call script event command. ║
║ │ 2. Type this (replace id with an event id): ║
║ │ $game_map.events[id].color = Color.new(red, green, blue(, alpha)) ║
║ │ return true ║
║ ├─ Example usage? I may still be confused. ║
║ │ $game_player.color = Color.new(100, 100, 100, 100);return true ║
║ │ $game_player.color = Color.new(200, 0, 200, 255);return true ║
║ │ $game_player.color = Color.new(200, 0, 200);return true ║
║ │ ║
║ │ ► zoom_x and zoom_y. ║
║ ├─ How do I change the sprite's x-axis zoom level? ║
║ │ For players: $game_player.zoom_x = value ║
║ │ For events: $game_map.events[id].zoom_x = value ║
║ ├─ How do I change the sprite's y-axis zoom level? ║
║ │ For players: $game_player.zoom_y = value ║
║ │ For events: $game_map.events[id].zoom_y = value ║
║ │ ║
║ │ ► Mirror. ║
║ ├─ How do I flip character sprites horizontally? ║
║ │ For players: $game_player.mirror = true ║
║ │ For events: $game_map.events[id].mirror = true ║
║ └─ Okay, how do I unflip them? ║
║ For players: $game_player.mirror = false ║
║ For events: $game_map.events[id].mirror = false ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ ■ Methods Aliased: ║
║ ├─ update - Sprite_Character < RPG::Sprite ║
║ └─ initialize - Game_Character ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ ■ Changelog: ║
║ ├─ Version 1.1 (5/10/09) - Replaced attr_reader with attr_accessor. ║
║ └─ Version 1.2 (5/12/09) - Updated the zoom stuff. (More info below) ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ ■ About Version 1.2 change: ║
║ Originally, the value '1.0' for properties zoom_x and zoom_y stood for ║
║ the character sprite's actual size. I felt like trying to explain that in ║
║ the instructions of this script and add-ons made to it would just confuse ║
║ some people. So I wanted to make the value 100.0 denote the actual pixel ║
║ size of the sprite. ║
╚══════════════════════════════════════════════════════════════════════════════╝
=end

#╔═════════════════════════════════════════════════════════════════════════════╗
#║ ■ Customize ║
#╚═════════════════════════════════════════════════════════════════════════════╝
class PK8
CharacterSpriteZoom100 = true
# If false, sprite's zoom level value 1.0 would denote actual pixel size.
# If true, sprite's zoom level value 100.0 would denote actual pixel size.
end

#===============================================================================
# ** Game_Character
#===============================================================================

class Game_Character
#-----------------------------------------------------------------------------
# * Public Instance Variables
#-----------------------------------------------------------------------------
attr_accessor :tone
attr_accessor :angle
attr_accessor :zoom_x
attr_accessor :zoom_y
attr_accessor :mirror
attr_accessor :color
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :pk8_character_sprite_addons_initialize, :initialize
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize(*args)
@tone = Tone.new(0, 0, 0, 0)
@angle = 0
@zoom_x = (PK8::CharacterSpriteZoom100 ? 100.0 : 1.0)
@zoom_y = (PK8::CharacterSpriteZoom100 ? 100.0 : 1.0)
@mirror = false
@color = Color.new(0, 0, 0, 0)
pk8_character_sprite_addons_initialize(*args)
end
end

#===============================================================================
# ** Sprite_Character
#===============================================================================

class Sprite_Character < RPG::Sprite
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :pk8_character_sprite_addons_update, :update
#-----------------------------------------------------------------------------
# * Update
#-----------------------------------------------------------------------------
def update
pk8_character_sprite_addons_update
self.tone = @character.tone#Tone.new(104, 124, 140)
self.angle = @character.angle
if PK8::CharacterSpriteZoom100 == true
self.zoom_x = @character.zoom_x / 100.0
self.zoom_y = @character.zoom_y / 100.0
elsif PK8::CharacterSpriteZoom100 == false
self.zoom_x = @character.zoom_x
self.zoom_y = @character.zoom_y
end
self.mirror = @character.mirror
self.color = @character.color
end
end

It gives Game_Character (ie, Game_Event & Game_Player) classes the following methods, which you can use like...

$game_player.angle = ?
$game_player.color = ?
$game_player.tone = ?
$game_player.opacity = ?
$game_player.zoom_x = ?
$game_player.zoom_y = ?

I've also got his other scripts which have commands like .change_<property>(target_value, duration), just PM me if you need them because I think his website with his scripts are down.

Enjoy :thumb:

PS: If you're using the MACL with this, you'll be encountering a really hard to find error. Simply do a Search All and find macl_gmplyr_init and change it to a super if you use this script.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top