Code Monkey home page Code Monkey logo

Comments (8)

ivanpopelyshev avatar ivanpopelyshev commented on June 10, 2024 1

How width/height is calculated: https://github.com/pixijs/pixi-tilemap/blob/master/src/RectTileLayer.ts#L105

For every tile you add, minX maxX is calculated.

What exactly is empty tile?

from tilemap.

ivanpopelyshev avatar ivanpopelyshev commented on June 10, 2024

If you mean that "tilemap should store width/height independently and ignore tiles that go out of those bounds" - no, sorry, those fields are calculated , its your problem to store width/height you want in your own tilemap. If you guys want different w/h - override the setter getter, like its done in pixi TilingSprite or Sprite

from tilemap.

ivanpopelyshev avatar ivanpopelyshev commented on June 10, 2024

also you can override calculateBounds of CompositeRectTileLayer or just RectTileLayer to take your own _$_width _$_height local vars , for example.

from tilemap.

blurymind avatar blurymind commented on June 10, 2024

Thank you for explaining :)

I did a manual calculation on gdevelop's wrapper for pixi-tilemap, but it would be nice if we could have these be calculated and stored by pixi-tilemap somewhere :)
Having the absolute width/height of the resulting tilemap is very useful when used in game engines which require it.

Gdevelop uses this to do the bounding box of the object, which has an effect on

  • whether the object gets rendered at all (if the bounding box is incorrect size, this leads to gdevelop thinking its not in the camera view and it doesnt render it at all sometimes)
  • being able to select the tilemap in the engine's IDE - to move and resize it

from tilemap.

blurymind avatar blurymind commented on June 10, 2024

I am silly, we never add these empty tiles to pixi tilemap - so it has nothing to work with for estimating proper boundaries.

@ivanpopelyshev I think I will close this bug, the fault is in the wrapper- since it never tells pixi-tilemap about them. But how do we tell to pixi-tilemap to change it's width/height externally? That would be incredibly useful for our case

from tilemap.

ivanpopelyshev avatar ivanpopelyshev commented on June 10, 2024

override calculateBounds() to add minX/maxX/minY/maxY that you specify in it :) , just use addFramePad two times - one for real tiles , one for your extra bounds

from tilemap.

ivanpopelyshev avatar ivanpopelyshev commented on June 10, 2024

At the same time, you have to do something about "width/height" property, if you want to use it for your own set bounds, and not pixi calculated ones.

from tilemap.

blurymind avatar blurymind commented on June 10, 2024

@ivanpopelyshev you make it sound like it would be simpler to just store it in my wrapper's variables - like I did on the PR at gdevelop 😄

sorry for raising a false alarm, took me a bit to realize it

from tilemap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.