Giter Club home page Giter Club logo

Comments (4)

williammalone avatar williammalone commented on July 2, 2024

A tile object is an object with two properties:

  1. "src" is the path and filename of the image
  2. "id" is an optional property which can be used when defining the order of the tiles in the tileCollection

Here is an example of a tileCollection consisting of 4 tile instances. The top two tiles are the same sky image and the bottom two tiles are two different ground images:

var background = BLOCKS.tileCollection({
    order: [["sky", "sky"], ["groundLeft", "groundRight"]],
    tiles: [{
        id: "sky",
        src: "mars-surface.png"
    }, {
        id: "groundLeft",
        src: "ground-left.png"
    },  {
        id: "groundRight",
        src: "ground-right.png"
    }]
};

from blocksjs.

JumpLink avatar JumpLink commented on July 2, 2024

Do I need to use BLOCKS.preloader first or something like this? I get this error: "Cannot read property 'width' of undefined"

from blocksjs.

williammalone avatar williammalone commented on July 2, 2024

Yes, that should fix the issue. The tileCollection expects a preload loaded image since it uses the image dimensions to define the tile size. I'll look into adding a warning. You can use the BLOCK.preloader or if you want to preload the images yourself just assign the preloaded image to and "image" property for each of the tile definitions.

from blocksjs.

williammalone avatar williammalone commented on July 2, 2024

I removed the requirement for preloading the first tile image before creating a tileCollection in release 0.5.13. The image will still need to be loaded but the tileCollection should stay out of error town until the first tile image is loaded.

@JumpLink Please let me know this resolves your issues.

from blocksjs.

Related Issues (2)

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.