Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Renderables #267

Closed
aaschmitz opened this issue Aug 25, 2013 · 2 comments
Closed

Problem with Renderables #267

aaschmitz opened this issue Aug 25, 2013 · 2 comments

Comments

@aaschmitz
Copy link
Contributor

Hi

Some issues I have detected with lastest 0.9.9 version (25/08):

  1. When running the code (in entity update) this.renderable.angle += 0.01; if the entity is in contact with some collision map (for example, one tile with type "solid" in Tiled), the entity is not rotated. If the same code is run without the entity is in contact with some collision, the same works.

  2. In the code:

init:
this.renderable = game.texture.createAnimationFromName([ "texture1.png", "texture2.png", "texture3.png"]);
this.renderable.addAnimation ("walk", [0, 1]);
this.renderable.addAnimation ("crouch", [2]);

update:
if (me.input.isKeyPressed("crouch"))
this.renderable.setCurrentAnimation("crouch");
else
if (me.input.isKeyPressed("left")) {
this.renderable.setCurrentAnimation("walk");
this.flipX(true);
this.vel.x = -this.accel.x * me.timer.tick;
} else
if (me.input.isKeyPressed("right")) {
this.renderable.setCurrentAnimation("walk");
this.flipX(false);
this.vel.x = this.accel.x * me.timer.tick;
}
else
this.vel.x = 0;

If I press an arrow key and then the "crouch" key, the crouch animation is displayed. if I am stopped and press straight down the crouch key, the animation is not executed.

  1. The message is shown in the browser console (Google Chrome): "Uncaught TypeError: Cannot call method 'getEntityByProp' of null melonJS-0.9.9.js: 1264"

Very Important: the issues above not exist with version 0.9.9 of the day 24/07 I was using. If I return to the other version, they disappear.

Thanks!

@parasyte
Copy link
Collaborator

Hi!

  1. Sounds like you may not be returning the proper value in your ObjectEntity's update() method. It should always be returning true if you want to redraw the object. For example, you may be returning false when the velocity is zero, or something.
  2. Again, you have to return true in your update() method if you want the redraw to happen. After setting the animation to "crouch", you could return true to display that animation frame.
  3. That one is odd; a full stack trace would help determine the cause of it.

The big thing that changed after 24/07 was the addition of ObjectContainer (#59). But it doesn't really explain why that would break code that seems to work before.

Could you share the "broken" source? I can have a look to see which code is at fault. Thanks!

@aaschmitz
Copy link
Contributor Author

Hi Jay

About the itens 1 and 2, the code below is in the end of update() method:

if ((this.vel.x !== 0) || (this.vel.y !== 0)) {
this.parent();
return true;
}
return false;

And now it's:

this.parent();
return true;

And works! The big question is because that coming back to version 0.9.9 of 24/07 the problems disappear? I did not change anything in the code, only the version of the engine.

About the item 3, I have used the last 0.9.9 version of 25/08, including the last version of debugPanel plugin and the error is gone!

Anyway thanks again and sorry for the inconvenience :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants