joket

Veteran
Veteran
Joined
Apr 24, 2021
Messages
298
Reaction score
70
First Language
English
Primarily Uses
RMMV
Hello everyone! Is there a way to show an icon on screen by a short script and withouth the window frame?
Let's say I want to show icon 44 at x = 250 and y = 350.
How should I write if it was a script?
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,367
Reaction score
970
First Language
Javascript
Primarily Uses
RMMZ
Hello everyone! Is there a way to show an icon on screen by a short script and withouth the window frame?
Let's say I want to show icon 44 at x = 250 and y = 350.
How should I write if it was a script?
pure script? with no plugins?

Something like this works but it's a bit odd to setup:
JavaScript:
const scene = SceneManager._scene;
scene._icon = new Sprite_StateIcon();
scene._icon.x = 250; scene._icon.y = 350;
$gameTemp._fakeBattler = new Game_Actor(1);
$gameTemp._fakeBattler._states = [4];
scene._icon.setup($gameTemp._fakeBattler)
scene.addChild(scene._icon);

That requires you to make a state and then pick that state that has the icon you want.
In the above example, it shows the icon from state #4 (poison in default MV)


Edit:
Ignore that ...that was really not a good way to do it lol
See below for a proper way. :)
 
Last edited:

joket

Veteran
Veteran
Joined
Apr 24, 2021
Messages
298
Reaction score
70
First Language
English
Primarily Uses
RMMV
Thank you for help. I think however that would be weird. I was trying to make huds with icons, where they change with 1/4, 2/4, 3/4, 4/4 of health of each character and I was going to show the state with an icon of an heart. Guess that's not the easiest way :(
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,367
Reaction score
970
First Language
Javascript
Primarily Uses
RMMZ
Thank you for help. I think however that would be weird. I was trying to make huds with icons, where they change with 1/4, 2/4, 3/4, 4/4 of health of each character and I was going to show the state with an icon of an heart. Guess that's not the easiest way :(
Oh I'm dumb sometimes... I don't know why I didn't think of this before lol
Code:
let iconIndex = 84, pw = 32, ph = 32;
let sx = iconIndex % 16 * pw;
let sy = Math.floor(iconIndex / 16) * ph;
const scene = SceneManager._scene;
scene._icon = new Sprite(ImageManager.loadSystem('IconSet'));
scene._icon.setFrame(sx, sy, pw, ph);
scene._icon.x = 250; scene._icon.y = 350;
scene.addChild(scene._icon);
Yep that's the way to do it. :)

Multiple icons:
JavaScript:
let data = [{index:84, x:200, y:350},{index:84, x:250, y:350},{index:84, x:300, y:350},{index:84, x:350, y:350}]
const scene = SceneManager._scene; scene._icons = [];
data.forEach(v => {
let icon = new Sprite(ImageManager.loadSystem('IconSet'));
let iconIndex = v.index, pw = 32, ph = 32;
let sx = iconIndex % 16 * pw; let sy = Math.floor(iconIndex / 16) * ph;
icon.setFrame(sx, sy, pw, ph); icon.x = v.x; icon.y = v.y;
scene._icons.push(icon); scene.addChild(icon);
});
That will place 4 heart icons. :)

Looks like this:
1675464360088.png
Helpful?
 
Last edited:

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
882
Reaction score
424
First Language
English
Primarily Uses
RMXP
Just asking. Wouldn't it be better to add it to Spriteset_Map instead of Scene_Map (or SceneManager._scene)?
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,367
Reaction score
970
First Language
Javascript
Primarily Uses
RMMZ
Just asking. Wouldn't it be better to add it to Spriteset_Map instead of Scene_Map (or SceneManager._scene)?
Really depends on what is wanted to achieve.. joket never said it was specifically the map scene that the icons where going to be added to. Could even be battle, menu, etc.
 

joket

Veteran
Veteran
Joined
Apr 24, 2021
Messages
298
Reaction score
70
First Language
English
Primarily Uses
RMMV
looks like exactly what I needed! Yes they should appear only during map playing, with them disappearing in main menu, battle and other scenes. Is it possible to bind a different icon to a percentage of health of each character? Let's say actor 1 has 2/4 health = icon 1
actor 2 has 1/4 health = icon 2...and so on? Maybe a plugin would work better, to constantly check health of party
 

ZombieKidzRule

I know just enough to be dangerous!
Veteran
Joined
Jan 9, 2022
Messages
782
Reaction score
903
First Language
English
Primarily Uses
RMMZ
EDIT: Oh, wait! My bad. I missed that this was for MV. I would think what I did would work in MV, but I don't know for sure. Sorry for any confusion. And I also noticed that you specifically asked for scripting. So again, my bad.

I just made something for fun that I think is similar to what you are looking for. It doesn't require a plugin and it is just showing the concept of displaying icons based on HP and removing icons as the HP goes down. This uses a simple parallel event to test the concept.

I made a quick video of what it looks like if you are interested. I can also post screenshots of the event if this is something that you think might be helpful.

Again, no scripting involved so it is far less elegant.

I hope this helps!

 
Last edited:

joket

Veteran
Veteran
Joined
Apr 24, 2021
Messages
298
Reaction score
70
First Language
English
Primarily Uses
RMMV
Yup that's what it is needed (actually I'll make 1 heart per actor and upgrade the graphic depending on the health %) However I'd say a parallel event or a common event in parallel would reduce performance a lot in comparison of a plugin. Isn't it? Great job however!
 

joket

Veteran
Veteran
Joined
Apr 24, 2021
Messages
298
Reaction score
70
First Language
English
Primarily Uses
RMMV
Oh I'm dumb sometimes... I don't know why I didn't think of this before lol
Code:
let iconIndex = 84, pw = 32, ph = 32;
let sx = iconIndex % 16 * pw;
let sy = Math.floor(iconIndex / 16) * ph;
const scene = SceneManager._scene;
scene._icon = new Sprite(ImageManager.loadSystem('IconSet'));
scene._icon.setFrame(sx, sy, pw, ph);
scene._icon.x = 250; scene._icon.y = 350;
scene.addChild(scene._icon);
Yep that's the way to do it. :)

Multiple icons:
JavaScript:
let data = [{index:84, x:200, y:350},{index:84, x:250, y:350},{index:84, x:300, y:350},{index:84, x:350, y:350}]
const scene = SceneManager._scene; scene._icons = [];
data.forEach(v => {
let icon = new Sprite(ImageManager.loadSystem('IconSet'));
let iconIndex = v.index, pw = 32, ph = 32;
let sx = iconIndex % 16 * pw; let sy = Math.floor(iconIndex / 16) * ph;
icon.setFrame(sx, sy, pw, ph); icon.x = v.x; icon.y = v.y;
scene._icons.push(icon); scene.addChild(icon);
});
That will place 4 heart icons. :)

Looks like this:
Helpful?
What about changing the icon depending of a given actor health?

Actor ID 1: HP 100% --> icon 1;
Actor ID 1: HP 75% --> icon 2;
Actor ID 1: HP 50% --> icon 3;
Actor ID 1: HP 25% --> icon 4;
Actor ID 2: HP 100% --> icon 5;
Actor ID 2: HP 75% --> icon 6;

and so on? On a script with a refresh rate of 60 frames? (or more, to avoid performance crash?)
 

Latest Threads

Latest Posts

Latest Profile Posts

Ryu.png
I turned one of the SV sprites into Ryu from Street Fighter lol. at least the head.
I really, really want the Magic story to be good, but instead we got today's chapter of the most predictable mish-mash of tropes with almost no personality. I let go of the physical game years ago, but I can't seem to let go of the story.
Just finished watching the last of the Final Destination movies. I'm digging every last water bottle out of that old van :p
Put off learning to drive for so long, I hope I don't run into any of-fences ..... (quietly leaves)
I introduced a new character to Mintabelle's Wonderland. Fufu the Raccoon! She's supposed to be a motherly daycare attendant, but when the power goes out, she becomes a monster. Rumor among kids says she causes these outages herself...

Forum statistics

Threads
129,805
Messages
1,205,326
Members
170,913
Latest member
lifina23
Top