Jump to content

createFromObjects layer scaling?


Ansis100
 Share

Recommended Posts

So I have a tilemap created from a Tiled .json file. The tile layers are scaled up 3 times. Works great. However, now that I'm trying to add an object layer, the objects seem to be in the wrong position, I presume, in the 3 times scaled down position. Game is a sidescroller.

Take this example - https://testarea.krizucentrs.lv/. The tiny orange guy up in the leaves? He's supposed to be down by the rock on the right side. Also, he's supposed to be much bigger. I can't create an object layer and just scale it, Phaser doesn't recognize it in the map.createLayer function.

How would I go about scaling the object layer correctly?

P.S. if I'm doing this wrong by scaling every tile layer and sprite then let me know, I don't know how to make the game appear bigger.

Link to comment
Share on other sites

EDIT: The fix below technically works, but it still makes positioning a pain. There's some conflicts, for example, the group position still shows the old one, so you have to multiply it by 3.

Kinda figured it out.

Set the group scale to get the correct position:

group.scale.setTo(3, 3);

Set the scale for individual sprites to get the correct size:

group.forEach( function(item) {
    item.scale.setTo(0.8, 0.8);
}

 

Edited by Ansis100
Nevermind, it's not fixed
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...