Off the top of my head:
You didn't do anything to "fade" it in and "fade" it out as you suggested. The way to do that would be:
>Create the text onCreated, set its alpha to 0 default. Assign it to "this.img"
>Inside a timeout loop:
>>If the player is inside, increase its alpha gradually to 1. This can be done as follows:
PHP Code:
this.img.alpha = min(this.img.alpha + 0.1, 1);
>>If the player is outside, decrease it gradually to 0 as follows:
PHP Code:
this.img.alpha = max(this.img.alpha - 0.1, 0);
>>>Note: I am using +/- 0.1 as a placeholder, obviously.
Additionally: I've never created text using that method, so I can't speak to its effectiveness. Is there any reason you skipped the more obvious showText() function?
showText(index, x, y, font, style, text); (??? - may have mixed up the last 3 arg's order)
Can still do something like:
PHP Code:
temp.img = this.img = showText(...);
img.layer = 8; // or changeImgVis(index, 8) // any number over 4 is likely overkill
img.zoom = 2;
etc;
Final thought: If you aren't using image indices 200 through 374 in that code, you might as well just use index 200. NPC's each have their own, local, image indices (as long as you're 200 or higher).