I am looking to create a window (which I know how to do) but tie it to an NPC so that when the npc is walking around theres another parallel process running that, for example, every 15 seconds a box will appear above that npc's head and some text might be display (kind of like he's shouting at people in the town) and then go away. The fade in and fade out method is easy to do. But how do you tie a window a npc or character?
When I say "tie it to them" it means that while the box is active and the npc is walks around that box is legit anchored to the npc.
So my question, to make this easy, is: What should I look at to make a box apear above an npc's head and follow said npc?
create a window above a npc's head
● ARCHIVED · READ-ONLY
-
-
What you'd need to do is get the screen X and Y that the NPC's sprite is being drawn at, and then position the window at least
window.y = Math.min(Graphics.height - window.height, Math.max(0, npc.y - window.height));That will guarantee, from a y-position standpoint, that the window will stay on the screen. screenX and screenY are functions for the Game_CharacterBase class, so I'd start there. -
And where do I look to say: Fetch NPC based on id x ?
-
I would attach it to the Sprite_Character class, and not to the Game_Character class. That's where all the drawing happens, and it already has a link to your event (or player, or follower, or vehicle). And if you look, you can see there is already handling for animations on events, and balloons on events, in there.
So yeah - I would look at Sprite_Character and see how balloons and animations are implemented, and then copy & adapt that.