Jump to content

Inserting Sprite into Anim Bug?


Ninjadoodle
 Share

Recommended Posts

@Ninjadoodle

game.addAsset('anim1.png');
game.addAsset('anim2.png');
game.addAsset('anim3.png');
game.addAsset('sprite.png');

game.createScene('Main', {
    init: function() {
        var anim = new game.Animation([
            'anim1.png',
            'anim2.png',
            'anim3.png'
        ]);
        anim.play();
        anim.addTo(this.stage);
        
        var sprite = new game.Sprite('sprite.png');
        sprite.position.set(100, 100);
        sprite.addTo(anim);
    }
});

Seems to be working fine here. Can you give me code example?

Link to comment
Share on other sites

Hi @enpu

In the case below, I'm putting the anchor point of the anim into the center.

As far I can tell, when I insert the sprite, the sprite's top left corner should sit against the anim's center.

It however sits as if the anim's anchor was still at (0, 0).

this.anim = new game.Animation([
    'tile1.png',
    'tile2.png',
    'tile3.png',
    'tile4.png'
]);
this.anim.speed = 4;
this.anim.play(frame);
this.anim.anchorCenter();
this.anim.position.set(x, y);
this.anim.interactive = true;
this.anim.addTo(game.scene.mg);

var sprite = new game.Sprite('tile.png');
sprite.addTo(this.anim);

 

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