Jump to content

Global to Local


Recommended Posts

Hi there, trying to convert global particle shooting sprite coordinates to local value to attach them later for my space ship. Wana use this coordinates to simulate hit effect (sprite animation) which will be attached to ship with addChild. Tho have problems, seems toLocal and toGlobal doesn't work for some reason... using Phaser CE, it should be fine there, tho when i searched for examples, almost nothing at all, only using in groups and what about situations when y just have some random sprite?

collide(entity) {
        let x = entity.toLocal(this.body.pivot, this.body.sprite);
        let y = entity.toLocal(this.body.pivot, this.body.sprite);
        let effect = this.addChild(this.game.make.sprite(x, y, 'hit'));

This = player class


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