Jump to content

Confused About PixiJSv4's Main Loop?


JeZxLee
 Share

Recommended Posts

Hi,

I don't understand PixiJSv4's main loop and how it works:

<script>
    function gameLoop()
	{
		FrameCount++;
	
		setTimeout(gameLoop, FrameRate);		

		state();
		
		renderer.render(stage);
	}
	
<!-- "A 110% By Team www.16BitSoft.com!" -->	
</script>
function play()
{	
	var CurrentTime = new Date().getTime();
	if (CurrentTime > NextSecond)
	{
		FPS = FrameCount;
		FrameCount = 0;
		NextSecond = CurrentTime+1000;
		
		if (ScreenToDisplay == PlayingGameScreen && PAUSEgame == false && GameOver == 0)
		{
			if (SecondsLeft > 0)  SecondsLeft--;
			else
			{
				PlayEffect(EffectMinuteBell);
				
				if (MinutesLeft > 0)
				{
					MinutesLeft--;
					SecondsLeft = 59;
				}
				else
				{
					PlayEffect(EffectGameOver);
					
					GameOver = 250;
				}
			}
		}
	}

	GetInput();

	DisplayScreen();
	
	ProcessButtons();
	ProcessArrowSets();
	
	FPSText = ""+FPS+"["+MouseX+","+MouseY+"]";
	if (FPSmessage != null)  TextSprites[FPSmessage].text = FPSText;
	
	CheckForBrowserResize(false);
}

How does "gameLoop" call "Play" ?

Thanks!

JeZxLee

Link to comment
Share on other sites

Well in the code you posted, it doesn't (unless state calls it, whatever that fn is). Also PixiJS doesn't have a loop, the loop only exists in user-land (or in PIXI.Application, but you aren't using that here).

You can always put a breakpoint in `play` and look at the call stack.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...