Heya,
So, basically I'm trying to fade all objects of a certain type when a player character walks behind them, for example trees:
function obj_fade(int obj_id) {
if (player.IsCollidingWithObject(object[obj_id])) {
if (object[obj_id].Transparency != 40) {
object[obj_id].Transparency++;
//Wait(0); //ignore
}
}
else {
object[obj_id].Transparency = 0;
}
}
function room_RepExec()
{
obj_fade(oTree2.ID);
obj_fade(oTree3.ID);
}
What would be the easiest way to run one line of code in RepExec to check if the charter is behind object type tree?
Cheers in advanced as always.
You can automate this almost completely:
1. create a custom bool property (like "walkbehind_fade") and set it to true for all relevant objects
2. call this to your global rep_exec:
void HandleFadingObjects() {
for (int i = 0; i < Room.ObjectCount; i++) {
if (!object[i].GetProperty("walkbehind_fade")) continue; // skip other objects
int dy = object[i].Y - player.y;
if (dy < 0) continue; // player is in front of object
int hw = Game.SpriteWidth[object[i].Graphic] / 2;
int dx = object[i].X - player.x;
if (dx < -hw || dx > hw) continue; // player not behind horizontally
if (dx < 0) dx = -dx;
object[i].Transparency = (hw - dx) * 100 / hw;
}
}
Not tested!
Thanks Khris, I've not tested your code either but I had completely forgotten about custom properties and I see where you was going with your code snippet,i shall go from there.