Sign in to follow this  
Phantasm

Phaser and minimaps

Recommended Posts

Hey guys. Been working with phaser for a bit now, and i'm currently trying to make a minimap (overview of a fixed region in my current state). That said, there is not much documentation on how to do something like this, and I am still a newbie to phaser, so it's giving me  hard time. 

Here are the links i<ve already read :

-http://www.html5gamedevs.com/topic/14930-creating-a-mini-map-from-a-render-texture/

-http://www.html5gamedevs.com/topic/14182-creating-a-mini-map-in-phaser/

 

What I have tried is using a bitmap of the state's layer, and putting it in a square on the top right of my screen. Now, I am ok with the palcement, drawing, etc. I have a square with the texture inside it. 

The problem is, I can't get the good region to show inside the minimap. I have weird graphical glitches when I move, and it shows a 1:1 of the nearby background.

 

Heres the snippet for the creation and update of my minimap

MyGame.Hud.prototype.drawMinimap=function(){
	if(this.miniMap){
		this.miniMap.destroy();
	}

	///
	// Init vars
	///
	var heightMax = 200;
	var widthMax = 200;
	///
	//  //
	///

	if (this.miniMapBitmap == null)
	{
		this.miniMapBitmap = MyGame.game.add.bitmapData(widthMax, heightMax);
		this.miniMapBitmap.ctx.beginPath();
		this.miniMapBitmap.ctx.rect(0, 0, widthMax, heightMax);
		this.miniMapBitmap.ctx.fill();


	}
	else
	{
		var area = {
			x: 0 ,
			y: 0 ,
			width: 1200,
			height: 1200
		}
        //testLayer is a state layer
		this.miniMapBitmap.copyRect(testLayer, area, 0, 0, 1);
	}
	this.miniMap = MyGame.game.add.sprite(MyGame.game.camera.width - 200, 0, this.miniMapBitmap);
	this.miniMap.fixedToCamera = true;

This is called on player movement.

Note that the area var is set to testing parameters, since I have no clue on what it should be (The other links didn't help)

 

I'd love to have your more knowledgeable opinions on this!

Thanks in advance

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.