Get data from PlatformCharacter
Janne

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.

All 3 Comments
Gio

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

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

Thank you. That worked like charm!

Post a reply
Add Attachment
Submit Reply
Login to Reply