Scroll factor and bounds



  • Hi, I have FlxSpriteGroup with some FlxSprites ini it. This group has height of game but width is wider as game width.
    I centred this group and than added

    FlxG.camera.setScrollBoundsRect(map.x, map.y, map.width, map.height);
    

    to set bounds.

    On update:

    override public function update(elapsed: Float) {
            super.update(elapsed);
            if (FlxG.keys.pressed.LEFT ) {
    		FlxG.camera.scroll.add(-10);
    	}
            if (FlxG.keys.pressed.RIGHT) {
    		FlxG.camera.scroll.add(10);
    	}
    }
    

    Scroll works fine and limits are correct so camera stops on bounds, but as soon as I change map.scrollFactor.x = 3 it scroll out of bounds. I am doing something wrong?


Log in to reply