Code Monkey home page Code Monkey logo

Comments (10)

alamboley avatar alamboley commented on May 22, 2024

Hello, your updateAnimation function is called by the update & attack method. It's probably not what you want... ?

from citrus-engine.

JonathanReisCom avatar JonathanReisCom commented on May 22, 2024

Actually, to call or not call the updateAnimation() inside attack() has no importance, I pulled out the call and the effect remains the same.
The fact is that when I call this line:
(view the AnimationSequence). onAnimationComplete.addOnce (attackFinishedAnim);
AttackFinishedAnim function is performed once or twice and then no longer runs.

She should infinite loop every time the animation ends, and it does not.

from citrus-engine.

alamboley avatar alamboley commented on May 22, 2024

(view the AnimationSequence). onAnimationComplete.addOnce (attackFinishedAnim);

You've used addOnce, so attackFinishedAnim function will perform only one time!

from citrus-engine.

JonathanReisCom avatar JonathanReisCom commented on May 22, 2024

The function attack () is executed when "_isAttacking = false" as shown inside updade ().
So when I run onAnimationComplete.addOnce, I am referring only 1 attack, when I restart the process, the hero will run the second attack, the function is called again, then run again another onAnimationComplete.addOnce

But anyway, I changed the line to
(view the AnimationSequence). onAnimationComplete.add (attackFinishedAnim);
And got the same result.

The result is different in your test?

from citrus-engine.

alamboley avatar alamboley commented on May 22, 2024

I don't have material to test.

Could you show us the updateAnimation function?

Also I've heard that it may have a bug in Starling 1.3 concerning animation complete: http://forum.starling-framework.org/topic/animation-eventcomplete-fires-early not sure if it was baked into Starling 1.3

Also it seems more related to Starling itself than Citrus Engine. Could you try a simple test running only on Starling and then on the Citrus Engine ? (You may want to duplicate the AnimationSequence class). Thanks!

from citrus-engine.

alamboley avatar alamboley commented on May 22, 2024

Do you still have the issue?

from citrus-engine.

JonathanReisCom avatar JonathanReisCom commented on May 22, 2024

I no longer have the problem. Decided to go for another logic.

from citrus-engine.

alamboley avatar alamboley commented on May 22, 2024

Ok, I hope everything is going well.

from citrus-engine.

alamboley avatar alamboley commented on May 22, 2024

Hey, I think what you're looking for is the StarlingArt.setLoopAnimations(tabAnimations) function ;)

Le 14 mars 2013 à 19:34, dkfast [email protected] a écrit :

Hey Aymeric, I know this post is closed, and i apologize for posting back on it, but i didn't know of another way to contact you. I seem to have a similar issue as to the original poster here. I am using a sprite sheet for all my animations for my hero. I have also been loosely following the "Braid" example to help with my custom hero animation frames. I have run into this issue and i just cannot seem to figure out no matter how many examples and posts i read. All my animations are now playing, however they all stop on the final frame and just stay there. for example if i hold down the "left" arrow my character runs left correctly, but when his animation frames end the character continues to move left, but he looks like he is frozen. I'm fairly new to Citrus and so far i love it, i just cant seem to figure out what im doing wrong on this. Thank you in advance for any help you may have.

below is the main part of my custom hero class, if you need to see more please let me know. I'm sure this isnt the best way to do things but again im kind of learning as i go along, reading through all the docs trying to figure it out.

public var canUseSword:Boolean = true;
public var isAttacking:Boolean = false;
public var swordExists:Boolean = false;
protected var _sword:Sword;
protected var _swordJointDef:b2WeldJointDef;
protected var _swordJoint:b2WeldJoint;

public function HeroClass(name:String, params:Object = null)
{
super(name, params);
}

override public function update(timeDelta:Number):void
{

var velocityX:Number = velocity[0];
var velocityY:Number = velocity[1];

if (_onGround && !isAttacking)
{
this.animation = "MainNeutral";
}

if (_ce.input.isDoing("right", inputChannel))
{
if (!isAttacking)
{
if (_onGround)
{
this.animation = "MainRunCycle";
this.velocity = [7,velocityY];
}
if (!_onGround) this.velocity = [5,velocityY];
_inverted = false;
}
}

if (_ce.input.isDoing("left", inputChannel))
{
if (!isAttacking)
{
if (_onGround)
{
this.animation = "MainRunCycle";
this.velocity = [-7,velocityY];
}
if (!_onGround) this.velocity = [-5,velocityY];
_inverted = true;
}
}

if (_ce.input.isDoing("jump", inputChannel) && _onGround)
{
if (!isAttacking)
{
this.animation = "MainJump";
this.velocity = [velocityX,-12];
onJump.dispatch();
}
}

if (canUseSword && _ce.input.isDoing("attack", inputChannel))
{
isAttacking = true;
swordExists = true;
if (_onGround) _animation = "MainBasicAttack";
if (_inverted) {
_sword = new Sword("Sword", {x:x - width, y:y, width:30, height:10});
} else {
_sword = new Sword("Sword", {x:x + width, y:y, width:30, height:10});
}
CitrusEngine.getInstance().state.add(_sword);

_swordJointDef = new b2WeldJointDef();
_swordJointDef.Initialize(_body, _sword.body, _body.GetWorldCenter());

_swordJoint = b2WeldJoint(_box2D.world.CreateJoint(_swordJointDef));    

_box2D.world.DestroyJoint(_swordJoint);
CitrusEngine.getInstance().state.remove(_sword);        

}

if (swordExists && _ce.input.getActionValue("attack") != 1)
{
isAttacking = false;
swordExists = false;
}
}


Reply to this email directly or view it on GitHub.

from citrus-engine.

dkfast avatar dkfast commented on May 22, 2024

Yes! that was it, thank you very much Aymeric. I actually figured that out soon after i messaged you, i tried removing my original post as to not bother you with it. But again, thank you for your time, i very much appreciate it!

from citrus-engine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.