Infinisecond

add/copy sprites to bitmapdata

Recommended Posts

I'm trying to create a bitmapdata with a single frame from a spritesheet and I'm getting nothing

 

I'm using this,

        bmd = game.add.bitmapData(800, 800);        bmd.add(new Phaser.Sprite(game, 50, 50, 'blocks', 3));        sprite = game.add.sprite(0,0,bmd);

but its showing nothing.

 

Am doing something wrong? I tried copypixels aswell and still got nothing, I tried adding the sprite in advance, nothing.

 

(I'm useing phaser 2.0.6)

 

Thanks for the help in advance.

Share this post


Link to post
Share on other sites

Still no luck with bmd.draw(sprite). But I did some digging in the Phaser examples and found this

http://examples.phaser.io/_site/view_full.html?d=display&f=render%20texture%20trail.js&t=render%20texture%20trail&phaser_version=v2.0.7&

so now my code looks like this

        texture = game.add.renderTexture(800, 800, 'mousetrail');        block = game.make.sprite(0, 0, 'blocks', 4);        texture.renderXY(block, 50, 50, false);        sprite = game.add.sprite(0,0,texture);

and just for the heck of it I made this

    var emitter;    var texture1;    var texture2;    var sprite1;    var sprite2;    function create()    {        game.stage.backgroundColor = '#2d2d2d';        texture1 = game.add.renderTexture(800, 800, 'mousetrail1');        texture2 = game.add.renderTexture(800, 800, 'mousetrail2');        emitter = game.make.emitter(0, 0, 200);        emitter.makeParticles('crystal', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12/*, 4, 6, 7*/]);        emitter.minParticleSpeed.setTo(-70, -70);        emitter.maxParticleSpeed.setTo(70, 70);        emitter.setRotation(0, 0);        emitter.setScale(1, 0, 1, 0, 7000);        emitter.gravity = 40;        emitter.start(false, 7000, 40);        sprite1 = game.make.sprite(0,0,texture1);        sprite2 = game.add.sprite(0,0,texture2);    }    function update()    {        texture1.renderXY(sprite2, 0,0, true);        if (!game.input.activePointer.position.isZero())        {        texture1.render(emitter, game.input.activePointer.position, false);        }        texture2.renderXY(sprite1, 0,0, true);    }

there's a picture of it below

post-9579-0-47190100-1409361824.jpg

Share this post


Link to post
Share on other sites

When in 2.0.5 I wanted to play with sprite colors to change clothes and skins colors of my soldiers...

Did not work.

 

It works in 2.0.7, but I fear it might again bring problems in the future, so I've just give up on the idea and made copies of the orginal sprite sheet, changed colors for colthes and no change in skin color.

It's heavier solution, since I load more files, but it's reliable.

 

Playing with bitmapdata with html5/phaser is not as reliable as with flash, that's how I feel about it, so I sacrifice a dozen of ko and I can sleep at night.

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...

  • Recently Browsing   0 members

    No registered users viewing this page.