moJoe

Villager
Member
Joined
Mar 10, 2021
Messages
5
Reaction score
1
First Language
English
Primarily Uses
RMMV
Yo!
Quick question: is there a way to change the .tint of only a section of a Sprite? For example:

JavaScript:
var IconSet = new Sprite();
IconSet.bitmap = ImageManager.loadSystem('IconSet');
IconSet.tint = 0x666666// Darken this only for one Icon as its clicked; keeping all other Icons with an unchanged tint;

Long story short I'm trying to create multiple buttons from one Sprite that changes tints per Button as a Button is clicked.

Any help would be greatly appreciated. :)
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,418
Reaction score
1,827
First Language
EN
Primarily Uses
RMMZ
The default Sprite#tint property applies to the entire Sprite object. To tint only an area of an image I think you'd have to manually draw a semi-transparent overlay, either by blitting (could damage the cache if you're not careful) or a separate Sprite...

Instead, I suggest simply making one sprite per button. You can still load the sheet as a single image, but adjust each button's frame so it only shows one clickable part per button. Then you should be able to tint each button separately.

You may find it helpful to check out the code for Sprite_Button (rpg_sprites.js) and how it is used in the core scripts (rpg_windows.js), especially if your buttons have rectangular hitboxes. :kaohi:

Alternatively you could search for a plugin that lets you interact with events and/or pictures by clicking, then do everything else with event commands, e.g. Tint Picture?
 

moJoe

Villager
Member
Joined
Mar 10, 2021
Messages
5
Reaction score
1
First Language
English
Primarily Uses
RMMV
@caethyril Yep, multiple sprite_buttons seems like the way to go. Just wanted to make sure the alternative of tinting a section wasn't possible before I dived in - considering that there's gonna' be a lot of buttons. Thank you!
 

Latest Threads

Latest Profile Posts

I've been getting into YuGiOh again!
Gameboy Tiles, Cure Writer's Block, Animations on Menu, Generate Tasks | RPG Maker News #40

How would you judge a game you played? Art/Graphics? Story? Gameplay?
Learn MV sales goal = 2%
NSFW game sales goal = 2500% (no jokes) :guffaw:

Forum statistics

Threads
111,377
Messages
1,060,596
Members
144,706
Latest member
DonTonyPepperoni
Top