Animations in Phaser do not function properly on touch screen devices, although they work seamlessly on desktop computers

In my phaser.js game, I have a variety of animations set up:

this.anims.create({
        key: 'catchingUp',
        frames: this.anims.generateFrameNumbers('android', { start: 0, end: 4}),
        frameRate: this.frameSpeed * 6,
        repeat: 0
    });

    this.anims.create({
        key: 'catchingDown',
        frames: this.anims.generateFrameNumbers('android', { start: 5, end: 9}),
        frameRate: this.frameSpeed * 6,
        repeat: 0
    });

    this.anims.create({
        key: 'topTop',
        frames: this.anims.generateFrameNames('androidTopTop', { start: 0, end: 9}),
        frameRate: this.frameSpeed * 6,
        repeat: 0
    });

    this.anims.create({
        key: 'downUp',
        frames: this.anims.generateFrameNumbers('androidUpDown', { start: 0, end: 4}),
        frameRate: this.frameSpeed * 6,
        repeat: 0
    });

Out of all the animations, only the one with the key downUp functions properly on every device. This animation shows the sprite moving its arm without crossing to the other side. However, when it comes to animations with keys catchingUp and catchingDown, instead of displaying the sprite, a black rectangle appears on phones and tablets while working correctly on a laptop. I initially thought that the issue lied within the animations themselves as the character was skipping frames. To resolve this, I created another animation called topTop but encountered the same problem. Further attempting to combine all the animations into one spritesheet resulted in all animations appearing as black triangles, including the previously functioning 'downUp' animation.

I came across a similar query where someone suggested using this.anims.generateFrameNames instead of this.anims.generateFrameNumbers. Despite implementing this change, the outcome remained consistent - functional on desktop but displayed as black triangles on other devices.

Prior to utilizing animated images, the game functioned seamlessly across all devices.

You can access the current state of the game at , and all the code can be found on https://github.com/chylinski82/androidCoop. The animations are located in Level.js and are triggered by basketUpRight.js, basketUpLeft.js, basketDownRight.js, basketDownLeft.js.

Answer №1

It appears that the issue may lie with the size of your sprite. By dividing your sprite into 4 separate lines, with dimensions of 2400 x 1000 instead of 9000 x 250, it should work on Android devices (even a width of 4500 does not work).
(I have not had the opportunity to test this on iPhone OS, but I believe the same issue would persist)

I have yet to determine the exact limit for the sprite's width, but there seem to be issues with sprites that have a large width.

Update: On Android 12, both the width and height are limited to 4096px for sprite animations, as confirmed through testing.

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

Implement a PUT method in Express that returns an empty array

**While working on a basic REST API, I encountered an issue with the PUT request using Express routes. When I trigger the PUT request, nothing happens and POSTMAN just returns an empty string. I am using MongoDB as my database along with Mongoose. enter ...

Is using Javascript objects a better alternative to Redux?

I'm in the process of creating my initial application with React and have opted to integrate Redux into it. Since incorporating Redux, it appears that setting a component state to a basic global JavaScript object would be a simpler approach. I unders ...

The JSON GET method for accentuated words in a string produces a NULL result on the Android platform

My Java code successfully sends values to the database, but when I use the GET method to retrieve the data, strings with accents are returning null. I have tried testing with UTF-8 encoding, but it doesn't seem to work. I'm unsure of what else to ...

The dynamic page fails to export with a static export in NextJS, resulting in an output error: "

I'm struggling to export a route in my NextJS 14 project. I've set the output to export and all routes are exporting correctly except for the dynamic ones. The folder for the dynamic route is not showing up in the output folder The version of Ne ...

Tips for efficiently storing data in the Laravel database using Ajax

I'm attempting to upload a product with multiple images to the database without refreshing the page. Despite not encountering any errors in the console, I am seeing a long block of text that starts like this: <script> Sfdump = window.Sfdump || ...

Object is not compliant with HTMLInputElement interface and cannot execute 'stepUp'

Currently, I am facing an issue with passing the selected value from a dropdown list of countries to a PHP file using AJAX. The goal is to take this value and then transfer it to another input field identified by the ID #tele. Here is the gist of my code: ...

Cease the act of sending submissions through JavaScript ajax requests

I need to prevent a form submission based on the result of an ajax request... Here is the code I attempted to implement: The chreg() function is supposed to return a boolean value from the ajax request, but it's not working! Javascript: function ch ...

Replicate the function of the back button following the submission of an ajax-submitted form to Preview Form

I am currently working on a multi-part form with the following data flow: Complete the form, then SUBMIT (using ajax post) jQuery Form and CodeIgniter validation messages displayed if necessary Preview the submitted answers from the form Options: Canc ...

Using a React component to trigger an action when the Enter key

I have a react component that needs to respond to the "Enter" key press event. class MyComponent extends Component { componentDidMount() { console.log('componentDidMount'); document.removeEventListener('keypress', t ...

I have the ability to effectively open a modal whenever necessary, but I struggle with closing it afterwards

I've been working on implementing a React bootstrap modal, and while I can successfully open it when needed, I'm running into issues with closing it. I'm not sure what mistake I might be making. Here's my markup: <Modal show={this. ...

The style from '<URL>' was not applied as it has a MIME type of 'text/html', which is not a compatible stylesheet MIME type

After attempting to run the angular application with the home component, an error appeared stating that styles were refused and images could not be found. It's puzzling because the CSS and image folder are located in the /src/assets folder. I have tr ...

Having trouble accessing data from MongoDB using Node.js and Express

Looking to retrieve data from Mongo DB using Node JS and Express JS? After creating a mongoose schema and exporting the module, you may encounter an issue where running the function returns an empty JSON object. Take a look at the code snippets below: Thi ...

The mystery of a JQuery response that remains elusive

Despite my best efforts, I've been struggling for hours with what seems like a simple and well-documented task. All I want to do is retrieve the result of a $.getJSON query without appending it to a div. While I can successfully alert the result withi ...

Having difficulty organizing an array using lodash and vueJS

I'm in the process of creating a one-page website to showcase COVID-19 cases in India. The base URL returns an array sorted alphabetically, but I want to sort it based on "totalConfirmed". Here's the code I have so far: <!DOCTYPE html> & ...

What is the best way to declare a variable within a VueJS v-if condition without it being visible?

In my code, I have a specific template that is displayed when a certain condition is met using a v-if statement. In this template, I need to set a variable to N/A, but I am struggling with how to accomplish this simple task. <span v-if="se ...

Unexpected HashLocationStrategy Issue in Angular 2 (ECMAScript 5)

Currently, I am trying to implement Hashlocationstartergy for routing in angular2 using ES5. Below is the code snippet I have used to bootstrap main.js: (function(app) { document.addEventListener('DOMContentLoaded', function() { ng. ...

Creating OneToMany references between existing MongoDB documents is a straightforward process that involves updating the relevant fields in

My first encounter with MongoDB has left me puzzled about creating references between documents that are already in the database. Unlike SQL, I am unsure how to establish relationships between collections. I have two collections: Films and Actors. The Fil ...

What is causing compatibility issues between html5lightbox and angular?

After integrating angular.js into my project, I encountered an issue with html5lightbox not working as expected. Instead of opening images and PDF files in a lightbox, clicking on a link takes me to another page. var app = angular.module('MyApp&apos ...

Leveraging MongoDB imported documents within DerbyJS

I am facing a challenge with my MongoDB collection which was not saved through my Derby app. My goal is to query that data and pull it into my Derby app. After figuring out the solution, I have written the following code snippet: get '/:year', ...

extract all elements from an array nested within another array

I am having difficulty extracting data from an array file in PHP. I was able to read it and convert it into a PHP array, but now I want to display the stored information in a table, however, I keep getting incorrect values. How can I retrieve the informat ...