Platforms = this.physics.add.staticGroup(); //Cannot read properties of undefined (reading 'add')?

Hi,

Have a problem which I need some help with.
Please view problem line of code at below URL link.
Let me know how to fix it, thanks!

Jesse Lee

https://bitbucket.org/jesseleepalser/phaser-engine/src/e43baa2984804b3bc7bd5fb0780c4f476b56a714/coreLogic.js#lines-64

It’s telling you this.physics is undefined on that line.

Add console.log(this) before that. Either this isn’t a scene or it’s a scene without physics, maybe if you forgot to enable the Arcade Physics plugin.

Tried that, got the following output in browser console:

initializeadd: initialize {scene: initialize, systems: initialize, events: initialize, displayList: initialize, updateList: initialize}anims: initialize {_events: s, _eventsCount: 3, game: initialize, textureManager: initialize, globalTimeScale: 1, …}cache: initialize {game: initialize, binary: initialize, bitmapFont: initialize, json: initialize, physics: initialize, …}cameras: initialize {scene: initialize, systems: initialize, roundPixels: false, cameras: Array(1), main: initialize, …}children: initialize {parent: initialize, list: Array(1035), position: 0, addCallback: ƒ, removeCallback: ƒ, …}create: ƒ create()data: initialize {parent: initialize, events: initialize, list: {…}, values: {…}, _frozen: false, …}events: initialize {_events: s, _eventsCount: 11}game: initialize {config: initialize, renderer: initialize, domContainer: null, canvas: canvas, context: WebGLRenderingContext, …}input: initialize {_events: s, _eventsCount: 0, scene: initialize, systems: initialize, settings: {…}, …}lights: initialize {scene: initialize, systems: initialize, lights: Array(0), ambientColor: initialize, active: false, …}load: initialize {_events: s, _eventsCount: 3, scene: initialize, systems: initialize, cacheManager: initialize, …}make: initialize {scene: initialize, systems: initialize, events: initialize, displayList: initialize, updateList: initialize}physics: initialize {scene: initialize, systems: initialize, config: {…}, world: initialize, add: initialize}plugins: initialize {_events: s, _eventsCount: 0, game: initialize, plugins: Array(0), scenePlugins: Array(0), …}preload: ƒ preload()registry: initialize {parent: initialize, events: o, list: {…}, values: {…}, _frozen: false}renderer: initialize {_events: s, _eventsCount: 4, config: {…}, game: initialize, type: 2, …}scale: initialize {_events: s, _eventsCount: 1, game: initialize, canvasBounds: initialize, parent: body, …}scene: initialize {scene: initialize, systems: initialize, settings: {…}, key: 'default', manager: initialize, …}sound: initialize {context: AudioContext, masterMuteNode: GainNode, masterVolumeNode: GainNode, destination: GainNode, locked: false, …}sys: initialize {scene: initialize, config: {…}, settings: {…}, game: initialize, sceneUpdate: ƒ, …}textures: initialize {_events: s, _eventsCount: 0, game: initialize, name: 'TextureManager', list: {…}, …}time: initialize {scene: initialize, systems: initialize, now: 8733, timeScale: 1, paused: false, …}tweens: initialize {scene: initialize, systems: initialize, timeScale: 1, _add: Array(0), _pending: Array(0), …}update: ƒ update()[[Prototype]]: Object
ph

Little lost here…

Jesse Lee

It looks like that object has physics, but it’s hard to tell.

Did you call this function as

InitializeAllVisualsForNewGame.call(this);

? What was the last change you made before the error happened?

Sorry, been awake 24+ hours… I need to sleep now and come back later with a fresh perspective.
I’ll revisit this when I wake up - thanks for your continued help and support!

Ok, that is fixed… have something new now, will make a new forum post