0

I have the following function in a scene that extends citrus.core.starling.StarlingState - it loads the PlayerRun animation and displays it on the screen. For the most part, this code works: I see the sprite on the screen (it's running in place).

protected final override function DrawScene ():void
{
    Player = new CitrusSprite ( "Player" );

    Player.velocity = [60, 0]; // Doesn't seem to have an effect
    Player.x = 40;
    Player.y = 40;

    var oClip:MovieClip = new MovieClip ( Resources.getTextures ( 
        "PlayerRun" ), 24 );

    Player.view = oClip;

    add ( Player );
}

I'm not sure how I'm supposed to use the velocity property - there's no documentation for it and no matter what numbers I use in the code above, it doesn't change the display: the animation plays but the sprite is stationary (it doesn't move horizontally as I would expect it).

Am I using the velocity property incorrectly? Does Citrus support sprite velocity or is this something I'd have to implement myself?

xxbbcc
  • 16,930
  • 5
  • 50
  • 83

2 Answers2

2

As it turns out, CitrusSprite has a property, updateCallEnabled that's false by default and disables calls to update(). Once I set this property to true, the code started working as expected.

xxbbcc
  • 16,930
  • 5
  • 50
  • 83
1

I haven't used Citrus yet, but looking at the source code it should work the way you've gone about it assuming that the update method is called on your player:

You can review the way the velocity property works at these locations:

I suspect you need to add the player to something that will queue it for updating.

Marty
  • 39,033
  • 19
  • 93
  • 162
  • Thank you for the response - I have the sprite on screen so I assumed that `update()` would be called on it - `add()` is called on the `StarlingState` in the code. I'll probably add an `update` override and see if it's called. – xxbbcc May 27 '15 at 14:35