Jump to content

how to use an image to fill an area


Recommended Posts


I'm new with phaser and i'm looking some stuff on internet and some tutorials and i can't find a way to take a image ( width 13px and height 400px) and fill an area of 400px*400px. I only want to use 1px of the middle to fill the middle of the area, the sides of the image and the area stay the same.


what should I do?


Thankx in advance.

Link to comment
Share on other sites

thanks you! lewster32, I've resolved this problem by using bimapdata.


there are the codes(now I'm filling an area of 830px*462px):


        var bmd = this.make.bitmapData(830,462);
        bmd.addToWorld(540, 340, 0.5, 0.52);
        var left_area = new Phaser.Rectangle(0, 0, 6, 462);
        var middle_area = new Phaser.Rectangle(6, 0, 1, 462);
        var right_area = new Phaser.Rectangle(7, 0, 6, 462);
        bmd.copyRect('bg_board_6_1_6', left_area, 0, 0);
        bmd.copyRect('bg_board_6_1_6', right_area, 824, 0);
        for(var i = 6; i < 824 ; i++) {
            bmd.copyRect('bg_board_6_1_6', middle_area, i, 0);
but its preformance seems not very good;
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.

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.


  • Recently Browsing   0 members

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