Jump to content

Help with Debugging...


AdamRyanGameDev
 Share

Recommended Posts

I am trying to debug a problem with dynamicBitmapText

The code was pretty much lifted out of phaser labs.io

in preload()

this.load.bitmapFont('robotoBitmap', 'media/roboto.png','media/roboto.fnt');

in create()
scroller = this.add.dynamicBitmapText(200, 200,'robotoBitmap', scrollerContent, 18);
scroller.setSize(200,200);

in update(time,delta)
scroller.scrollY += 0.03 * delta;
if (scroller.scrollY > 200)	{
	console.log('called!');
	scroller.scrollY = 0;
}

global vars
var scroller;
var scrollerContent = ['line1','line2','line3'];

I have entered the scene it is happening and with the console (chrome) i have inspected the "var scroller."

Depth, Alpha, Visible, valid xy pos, xy height all fine, the content is there and the png and fnt files are not empty!

I have put a console.log in the middle of the only update loop it is calling...

 

if (scroller.scrollY > 200)
	{
		console.log('called!');
		scroller.scrollY = 0;
	}

 and the console is logging 'called' every few seconds.

What/Where to do/go next? Any ideas much appreciated!

 

 

Link to comment
Share on other sites

The plot thickens... is this a bug?

I made a page exactly as follows

It is basically a smaller png and bitmap text sharing a x,y and with and a log on an changing depth..

<!doctype html> 
<html lang="en"> 
<head> 
    <meta charset="UTF-8" />
    <title>My Tester</title>
    <script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.js"></script>
    <style type="text/css">
        body {
            margin: 0;
        }
    </style>
</head>
<body>

<script type="text/javascript">
var config = {
        type: Phaser.AUTO,
        width: 800,
        height: 600,
        scene: {
            preload: preload,
            create: create,
            update: update
        }
    };


var game = new Phaser.Game(config);
	var scroller;
	var scrollerContent = ['line1','line2','line3'];
	var spriteSCROLLERs1;
	var text0s1;




function preload ()
{
    
    this.load.bitmapFont('desyrel', 'media/desyrel.png', 'media/desyrel.xml');
	this.load.image('spriteSCROLLERs1', 'media/beigeboard.png');
}

function create () 
{
    
	
	scroller = this.add.dynamicBitmapText(200, 200,'desyrel', scrollerContent, 55);
	scroller.setSize(200,200);
	scroller.depth = -2000;
	spriteSCROLLERs1 = this.add.image(200, 200, 'spriteSCROLLERs1');
	spriteSCROLLERs1.displayWidth = 100.0;
	spriteSCROLLERs1.displayHeight = 100.0;
	spriteSCROLLERs1.setDepth = 1000;
	
}

function update (time, delta)
{
    scroller.scrollY += 0.03 * delta;
    scroller.depth += 0.05 * delta;
	console.log(scroller.depth);
	if (scroller.depth > 2000)
    {
		scroller.depth = -2000;
		
    }
	
	if (scroller.scrollY > 300)
    {
		
        scroller.scrollY = 0;
		
    }
}

	

</script>

</body>
</html>

What is interesting/strange is that the bitmap text is only visible with depth <=0

and that at NO point will it overlap the png. It always goes 'under'

 

Is this desired behaviour? How do I get bitmap text visible on any thing (but the phaser container)????

Link to comment
Share on other sites

I think what's happening is that you are adding your bitmap text `scroller` to the scene before you add your image `spriteSCROLLERs1`. This means that `scroller` is going to render before the image does (meaning the image renders on top of it). You're overriding that behavior by using the `depth` property to get your desired outcome.

So you can do what you're doing here, add the image to the scene prior to adding the bitmap text, or you could modify their places in the display list after you add them in whatever order you like.

Link to comment
Share on other sites

Yeah I wondered the same thing and I had tried rearranging the order. It changed nothing. (that-s why I put my sprite covering half of the scroling text).  Thanks @snowbillr all the same!

The behaviour is a little erratic because while the text is visible when depth <=0 and not visible above depth> 0 in my example...

..however..if I make the other sprite on the screen visible=0 then the text stays visible at any depth.

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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