Hi,
great tutorial of Platform game.
How I get data from PlatformCharacter?
Example: in SpiderEnemy onUpdate function I need to get facing value from PlatformCharacter. Is that possible?
I try to use "wade.getSceneObject("PlatformCharacter").facing" but it does not work.
Thank you.
Get data from PlatformCharacter
Janne March 21st, 2019
All 3 Comments
Gio March 22nd, 2019
Hi
I think in that tutorial we do not explicitly store the heading. We probably should do. However what we do is this: we look at the velocity at any time, and when velocity.x changes sign we change animation.
So you could use either the velocity (when the character is moving) or the animation name to determine the heading. With the character that we use in the tutorial (her name is inaura) you would do something like this:
var animationName = _.inaura.getSprite().getCurrentAnimationName();
// animationName will be something like "idle right"
var heading = animationName.split(' ')[1];
Gio March 22nd, 2019
Actually that was wrong :) We DO store the heading, I just looked it up as I couldn't remember.
_.inaura.getBehavior('PlatformCharacter').facing
This should always be either 'left' or 'right'
Janne March 22nd, 2019
Thank you. That worked like charm!
Post a reply
Add Attachment
Submit Reply
Login to Reply