• Is there any way of using FlxG.camera.targetOffset? It seems to be read-only. I can make the camera follow a dummy object instead, but it seems to lag behind the actual target for a fraction of a second, causing the sprite to jitter.

    Another problem- whenever I use FlxG.watch it shows something like:
    null._myVar null
    Any idea what I'm doing wrong? Eg:

    class PlayState extends FlxState
    	var _myVar:Int = 123;
    	override public function create():Void
    		FlxG.watch.add(_myVar, "My Variable");
    	override public function update(elapsed:Float):Void

  • administrators

    Like with a lot of FlxPoint fields in the API, FlxG.camera.targetOffset is read-only - however, this only affects the reference to the point itself, so you can't assign a new point to it. However, you can still change the values of the point, for instance via FlxG.camera.targetOffset.set(x, y), or by setting its x and y properties directly.

  • Aha, now it makes sense! Thank you very much!

  • administrators

    Oh, and regarding FlxG.watch usage: you're using the API incorrectly. The first argument for add() is the object that contains the variable, the second argument is the variable name:

    This should work:

    FlxG.watch.add(this, "myVar");

  • Ha ha, I knew I'd feel stupid once I realized the mistake! It was worth it, good stuff.

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.