how add elapsed to `FlxG.watch.add(??? , "elapsed","upel");` ?



  • in my FlxState have update(elapsed:Float):Void function with internal variable elapsed, how i can addonelapsed into watch debug window?
    please replace ???? in code block to right syntax. i don't understand what dinamical object must place inside FlxG.watch.add(...), or may be it syntax must be placed inside create codeblock, etc

    override public function update(elapsed:Float):Void
    	{
    		
    		if (FlxG.mouse.pressed){
    			FlxG.watch.add(????,"elapsed","upel");
    			
    		}
    		
    		super.update(elapsed);
    		
    	}
    }
    

    this full code of PlayState.hx file

    package;
    
    import flixel.FlxG;
    import flixel.FlxSprite;
    import flixel.FlxState;
    import flixel.text.FlxText;
    import flixel.ui.FlxButton;
    import flixel.math.FlxMath;
    
    class PlayState extends FlxState
    {
    	
    	var _court:FlxSprite;
    	var _player0:Player;
    	var _player1:Player;
    	
    	override public function create():Void
    	{
    		
    		
    		_court = new FlxSprite(0, 0, "assets/images/court/court2.png");
    		add(_court);
    		_player0 = new Player(0, 0, "assets/images/players/15.png");
    		_player1 = new Player(500, 500, MenuState.ballcolor);
    		add(_player0);
    		add(_player1);
    		
    		
    		super.create();
    	}
    
    	override public function update(elapsed:Float):Void
    	{
    		
    		if (FlxG.mouse.pressed){
    			FlxG.watch.add(????,"elapsed","upel");
    			if (FlxG.mouse.screenX > 3668 / 2){
    				_player0.x = 3000;
    				_player1.move(0,FlxG.mouse.screenX,FlxG.mouse.screenY);
    			}
    			else{
    				_player0.x = 1000;
    				_player1.move(0,FlxG.mouse.screenX,FlxG.mouse.screenY);
    			}
    		}else{
    			
    			//_player1.move(_player1.actiontimer.elapsedTime);
    			//_player1.x+=_player1.actiontimer.elapsedTime+1;
    		}
    		
    		super.update(elapsed);
    		
    	}
    }
    
    


  • You can use FlxG.watch.addQuick("blahblah", elapsed).
    Also, elapsed equals to 1 / updateFrameRate, e.g. 0.01666 for 60 FPS



  • @starry-abyss
    thanx, worked.. now need restyle info and make notes for self)


Log in to reply