Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

89
Views
Is storing Phaser Containers computationally/space efficient? (2D game framework question)

This question is about Phaser.js, javascript game framework for creating games, though I think the question can probably be generalised to any framework like Pygame.

Say I want to represent different in-game locations with Phaser Containers, where each container contains many images. The containers appear slightly different (contain different images) every time they are rendered. A new container needs to be rendered every 1-2 mins or so when user navigates around the game.

Is it more computationally efficient if all my possible containers are stored in a container array, and they're toggled visible and invisible when needed? Or can they cheaply be recreated and re-rendered as and when you need them? However, if it's computationally efficient, will saving containers consume lots of memory?

Any help is appreciated, thanks!

7 months ago · Juan Pablo Isaza
1 answers
Answer question

0

One of the fastest ways is to store all images possible onto one single sprite sheet. That sheet gets loaded once during the initial loading of the game, and any and all displayed things are shown by copying pixels from the sprite sheet onto a single html canvas.

If a Phaser Container is a canvas, then having too many would slow down the game.

7 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs