Make teleporting objects less confusing



  • Recently I discovered that HaxeFlixel buffers last positions of objects to calculate overlap stuff.
    How about improving FlxObject.setPosition like this:

    public function setPosition(X:Float = 0, Y:Float = 0, teleport:Bool = false):Void
    {
    	x = X;
    	y = Y;
    	
    	if (teleport)
    		last.set(x, y);
    }
    

    The confusing effect that comes from just setting the position and not updating the last (honey shouldn't be taken):

    alt text


  • administrators

    Of course it's optional because of the flag argument, but I don't much like the idea of a flag argument for a simple function like this. Additionally, adding parameters, even optional ones, is technically a breaking change, because people might have overriden this function in a subclass (signatures have to match).

    Besides, what you're looking for might already exist withreset(x, y), which also resets some other collision-related variables.

    Cool-looking game btw! :)



  • @Gama11 , but reset also revives the object (not sure if dead object teleporting would collect the item though). It could lead to bugs like teleports-resurrectors... (not unlike the funny resurrection bug in my LD35 game)

    The art in this game is by the real artist, and not by me, that's why it doesn't suck :D



  • Why don't you just override the function? It shouldn't be too hard.



  • I can also wrap the function in my function, even as a static extension. But the problem is not in me, but in that it's a counter-intuitive poorly-documented hidden "feature" in general



  • @starry-abyss said in Make teleporting objects less confusing:

    I can also wrap the function in my function, even as a static extension. But the problem is not in me, but in that it's a counter-intuitive poorly-documented hidden "feature" in general

    I agree.



  • Omg, never thought someone else would experiencing this. I thought it was a problem on my end. Basically, this made me crazy for around a year. I ended up making the object non-solid before moving it, and making it solid again after the teleport. I second this idea, might be super troublesome for people.



  • As a simple variant, we could add an additional teleportTo function, and add a notice above the function setPosition declaration (which gets then in the API reference and IDE tooltip).
    But to write the notice, it'd be nice to know from devs what exactly that last field exists for :slight_smile:


Log in to reply