The "Array" function is not functioning correctly when used in an EaselJS CreateJS Container

I am currently developing a semi-OOP game and utilizing EaselJS as my chosen library. While I have made significant progress, I have encountered a persistent issue that is proving to be quite troublesome. The problem arises when I attempt to render out my tiles, as the tile container seems to be malfunctioning. It refuses to recognize the type "array" for some unknown reason. Here is the code snippet in question:

(function() {

var tile = function(array, _x, _y, spritesheet) {
  this.initialize(array, _x, _y, spritesheet);
}
tile.prototype = new createjs.Container();

tile.prototype.Container_initialize = this.initialize(array, _x, _y, spritesheet);
tile.prototype.initialize = function(array, _x, _y, spritesheet) {
    this.Container_initialize();
    this.x = _x * 120;
    this.y = _y * 120;

    this.tileArray = array; 

    this.tilesheet = spritesheet;

    for (var x = 0; x < this.tileArray.length; x++)
    {
        for (var y = 0; y < this.tileArray.length; y++)
        {
            console.log(this.tileArray[x][y]);
            var tileSprite = new createjs.Sprite(this.tilesheet, this.tileArray[x][y]);
            tileSprite.x = _x * 40 * x;
            tileSprite.y = _y * 40 * y;
        }       
    }
}

window.tile = tile;
}());

Answer №1

Make sure to exclude any parameters when setting up the Container_initialize method:

Assign this.initialize to tile.prototype.Container_initialize;

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Collisions of Arrays in PHP

A Small Observation After delving into the max_input_vars variable, I found myself immersed in the inner workings of PHP when it comes to handling arrays. This isn't so much a question as it is a way of answering my own query about why the max_input_ ...

Insert an array of objects into the td elements of a pre-existing table

Currently, I have a table where the td cells are intentionally displayed as blocks. My aim is to insert labels inside each of these td cells by creating spans with specific classes and then prepend them to the table cell. To achieve this, I am utilizing an ...

Loop through each item in order to modify the text within the pop-up using a for loop

Goal Upon clicking a .player, a popup should display with relevant data about that player fetched from players.js Issue: When clicking on a player, the event seems to trigger multiple times instead of just once. This results in retrievi ...

Guide to setting a checkbox as selected using the v-model value for vue-multiselect

Issue: The selected option checkbox is not getting selected, regardless of the checked state being true or false. Important Note: I always want the value model without the inclusion of the checked state in it. Refer to the image below for a visual repres ...

Creating a line that connects Point A to Point B using HTML, CSS, and JavaScript

Essentially, I am looking to create a line that connects point A (0vh|0vw) to point B (50vh|50vw). Initially, I considered using a div with a border and a 1px height that is rotated to achieve the desired effect. However, the issue arises when the size ...

Can we establish communication between the backend and frontend in React JS by utilizing localstorage?

Trying to implement affiliate functionality on my eCommerce platform. The idea is that users who generate links will receive a commission if someone makes a purchase through those links. However, the challenge I'm facing is that I can't store the ...

Angular Resolve Upon Application Reloading

Is there a way to postpone the initialization of my Application Controller (similar to using the 'resolve' attribute in the router) when reloading a page? Or more importantly, how can I delay the rendering of the view until my controller has succ ...

What is the best way to apply multiple filters to an array in PHP?

I am working with an array of simple stdClass objects where each object contains basic information like propertyID, price, and number of bedrooms. object(stdClass)[408] public 'propertyID' => string '2232' (length=4) public &apo ...

Connecting the mat-progress bar to a specific project ID in a mat-table

In my Job Execution screen, there is a list of Jobs along with their status displayed. I am looking to implement an Indeterminate mat-progress bar that will be visible when a Job is executing, and it should disappear once the job status changes to stop or ...

Choosing various choices using AngularJS

My goal seems simple using vanilla JS, but with AngularJS, I'm looking for the best way to achieve it within the framework. I aim to update the selected options in a multiple select box without adding or removing any options. Below is a snippet of my ...

Parsing JSON arrays into Java arrays, lists, or maps

Here is the initial code snippet I have, along with the imports: import java.sql.Array; import java.util.Map; import org.json.simple.*; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import dataProcessing.Config. ...

What is the best way to send the current ID for data deletion in React?

Here is my current code snippet: var html = []; for (var i = 0, len = this.props.tables.length; i < len; i++) { var id = this.props.tables[i]._id;//._str; html.push( <div key={id} className="col-xs-6 col-md-3"> ...

Why is it that individuals with [1].a are unable to utilize the properties from the User class?

Why is it that people are unable to access properties directly from the User class, but instead need to access them nested through proto ?! class User { constructor(name, age) { this.name = name; this.age = age; } ...

What is the best way to include a substantial amount of HTML in a Vue.js template?

As a newcomer to Vue.js, I have a question regarding the rendering of a large amount of HTML in a Vue.js template. When I include around 500 lines of plain HTML code in my template and run npm run dev the compiling process becomes extremely slow or d ...

Mastering the art of leveraging generics within React applications

I am currently working on resolving issues in an outdated React application that does not utilize Typescript. In order to incorporate the Select2 component from the Blueprintjs library, I need to convert it to a non-generic reference. Using Typescript, t ...

What is the best way to determine the width of a CSS-styled div element?

Is there a way to retrieve the width of a div element that is specified by the developer? For example, using $('body').width() in jQuery will provide the width in pixels, even if it was not explicitly set. I specifically need to access the width ...

The phenomenon of lithophane in Three.js

Is there a way to achieve the Lithophane effect using three.js? . I've experimented with different materials featuring transparency and opacity, but haven't been successful. <html lang="en"> <head> <title>Lith (Three. ...

Incorporating a MUI5 theme into a custom emotion-themed application

I'm currently working on an application that incorporates multiple themes. One of these is a Material UI theme specifically designed for MUI v4, while the other is an emotion theme used by non-MUI components. In my attempt to transition to MUI v5, I ...

Using the AngularJS limitTo filter in ngRepeat for an object acting as a dictionary

Can the limitTo filter be used on a ngRepeat directive that is iterating over the properties of an Object instead of items in an Array? Although it is stated in the official documentation that the limitTo input should be an array or string, I am curious i ...

Struggling to restart CSS3 animation following an Ajax response

Below is an example of an HTML form: <form method="post" action="camount.php" id="loginForm"> <span id="heading"> Username: <input type="text" name='us' id='us'/> ...