HasFX

Hello,

New here, so please bear with me if this is a silly question... Is there a good reason why there isn't a HasFX in orxObject? It has AddFX and RemoveFX, so it would really simplify things if one could poll.

I think this would also make the "locking" to avoid adding multiple FX simpler... or perhaps we could also have a "ListFX" or whatever.

Does this make sense?

Comments

  • edited November 2011
    Hi duenez,

    Well, there's actually no reason behind the absence of this function beside the fact that no one so far had the use of it, I think.
    I usually know what FXs are on one objects as either I'm using fire&forget kind of FXs or long lasting looping FXs that I'll remove when I don't need them anymore (remove a FX that isn't there won't do anything).

    Lastly, when I don't want to duplicate a FX I simply call AddUniqueFX() that will make sure to add an FX only if it's not already present.

    I guess that you found the "locking" in the tutorial where it's only for education purpose as I never write such code in a real game. I should probably refresh some tutorials to make sure not to give bad practices (most of the time I write in the comments that it's not a practical use of a feature but simply the only thing I could think of to show some features at the time while not having to write 10s of lines of code).

    Out of curiosity, would you need the HasFX() for another use than the AddUniqueFX() situation?
  • edited November 2011
    Hey iarwain,

    Thanks for the prompt response... I'll use UniqueFX. I do think the HasFX could still be useful... Say you have a shooter in which you can deactivate an enemy for a while when you shoot it. If I have a visual FX applied to them when they are deactivated, I can immediately know that I don't have to, say, worry about collisions with them.

    Another example... say your character flashes after being hit, giving him a bit of invulnerability. This is a classical example, and a HasFX would make this behavior trivial to code.

    Since I am new, I still don't know the traditional way of doing things like this activation/deactivation, but it seems that knowing if an object has an FX would be all round useful.

    Thanks again!
  • edited November 2011
    Hi duenez!

    I see your point but I feel that you should approach the problem from the opposite.

    Taking the invulnerability example, I think you should store that status on your object (in your own structure linked to the orxOBJECT) and use it to activate/deactivate the effects it has, including the fact your object can't be damaged, FX, sound, etc.

    For me an FX is the result of a status change and not the status itself. Does it make sense?

    But yes, I can add a HasFX() accessor nonetheless. I'll try to do it next week.
Sign In or Register to comment.