Jump to content

Simple positioning of entity causing renderable error


Growler
 Share

Recommended Posts

In MelonJS 5.1, after I load the level and the player entity, I set the player's position somewhere else (testing positioning) via:

this.pos.x = 1000;
this.pos.y = 1000;

For some reason, melon fades the screen out to white, re-renders the entire environment (it seems), and the player entity doesn't appear. I also get error:

Uncaught TypeError: Cannot read property 'flipX' of undefined

Which is complaining at line this.renderable.flipX(...)

So it would appear the renderable is removed from the player entity. Moreover, other screen entities also appear to be destroyed, as I have logs in each entity's onDestroyEvent. All entities appear to be destroyed on a simple positioning of the player entity. 

Update: I tested logging the renderable and body property objects on the player entity before and after setting the position. Before, the renderable and body are both defined correctly according to the docs. After, both renderable and body are both undefined, yet the entity class is still instantiated.

Question: Why is the entity or entity's renderable removed and why does the screen fade out on a simple entity repositioning? 

Note: I do not have a player entity object directly added to the Tiled map. Instead, I have a "spawn entity" object where I place at the position of where the player entity should ultimately be instantiated at a certain point in the game. I also have alwaysUpdate = true on the player entity.

@obiot

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...