collinhover/impactplusplus

Help - Basic stuff

Closed this issue · 9 comments

Hi everyone,

I created a post in the impactjs forum, @Pattentrick helped me with some basics, but I have no idea of where to put the "override" method.

The thing is, I have differents sequences of animation for each action the player do. Depending of what "power" the player chooses, the hero changes his animation. This way I have Power1Jump, Power2Jump, etc.

Following the tutorials I did a custom "animsExpected", "animSettings" and overwrote the "updateCurrentAnim". Everything worked pretty well for jumping, climbing, moving, falling, idle, but for melee and shoot I cant figure how to check the action.

I even tryed to create a couple of "Hero" entities, but again I couldnt use playerManager or overwrite the "getPlayer()" function, simply because I'm kind of a dumb programming. My curve of learning its the longest.

If its not ask to much, dont close this issue please, I have a lot of doubts.

Thx!

Just to be clear, you want your player to have different sets of animations, depending on collected powerups? Like in “Kid Chameleon” or "Super Mario Bros. 3"?

http://youtu.be/H1Ui3ZDX9MI?t=46s

In the video you'll see how Mario collects a leaf and then has a different look after that. Is that the behaviour what you want? Or is this just about making a specific animation once your player did something? For example if you hit the “shoot” button, you want to play a shoot animation?

Hi there @Pattentrick

Exactly like Kid Chameleon. I asked for other help in another issue (#170) and my main example was kid chameleon.

If he changes "power" to a swordsman, melee animation must be with the one with a sword in the hand. If changes to club, animation changes to club or only the hand animation.

PunchX: {sequence: [30,31],frameTime: 0.1},
SwordX: {sequence: [32,33],frameTime: 0.1}
ClubX: {sequence: [34,35],frameTime: 0.1}

But the button input is the same for all of them. I only check the "current power" after push "melee" input.

I dont know* how to check in the updateCurrentAnim when the hero stopped the input of melee.

Thx again!

@leoportilho

Add this to your handleInput method of your player:

javascript
if ( ig.input.pressed('melee') ) {

switch( this.power ){
    case 'punch':
        this.animOverride('PunchX');
    break;
    case 'sword':
        this.animOverride('SwordX');
    break;
    case 'club':
        this.animOverride('ClubX');
    break;
}

}


Add a `power` property to your player. Once your player has a certain power, store it in the `power` property.

``` javascript```
if( hasCollectedNewPower ){

    this.power = 'club';

}

Depending on the name of the power, ++ will override the current animation with the desired one.

Warning: Overriding the animation in the handleInput method is quick and handy. But you should take a closer look at the documentation at this point and go with a "proper ++ solution":

https://github.com/collinhover/impactplusplus/blob/master/lib/plusplus/abstractities/character.js#L40

A better approach would be to override the updateCurrentAnim method with your own logic, based on the animsExpectedarray. Here is the original one:

https://github.com/collinhover/impactplusplus/blob/master/lib/plusplus/abstractities/character.js#L2596

I hope this information helps you a little bit. I am really busy at the moment, so I can't go in detail with the updateCurrentAnim method right now. But @collinhover has commented all the important parts, so I am sure you will figure everything out.

Thx @Pattentrick!

Worked like a charm.

I overwrote the "updateCurrentAnim" and put some code like this one below:

            if (this.jumping) {
                  anim = anims[this.power+this.getDirectionalAnimName("Jump")];
                   if (this.currentAnim !== anim) {
                       this.currentAnim = anim;
                        this.currentAnim.playFromStart(true);
                    }
                    return true;
                } 

If it's not to ask too much, dont close this issue already.

Thank you very much.

Hi everyone,

Basic stuff again, sry :(

I've read all the AbilityShoot and Ability looking for a setting that shift some pixels up the spawning laser. I believe that the language is being a wall to my comprehension. English is not my mother's language.

Today
Player..................................What I want (Like Cyclops from Xman, who shoots lasers from eyes)

(º º).......................................(º º) === Laser
|¬|...........................................|..|
|..|=== Laser..........................|..|
|..|...........................................|..|
/............................................/..\

Second thing,

how can I position the UIButton in the right down side of the canvas, I understood left up, right up, but I couldnt manage to put down on the canvas.

Thx @collinhover it worked very well.

Hi guys, @collinhover and @Pattentrick

I need some help again.

  1. I want to make something like shoot where I point:http://www.pointofimpactjs.com/tutorials/view/9/shoot-where-i-point. But after reading the documentation and the "top down" code example, I cant figure it out.

After that, I'll probably have some logic of directions. I'll try 8-directional animations. I only know that I have to override getDirectionalAnimName and lookAt function, maybe some more.

  1. Other thing is the jumpForce property. My hero has 3 "powers", each one jumps a different height. But I noticed that any value greater than jumpForce:8, it jumps the same, even if I change to jumpForce:50. There must be something else I couldnt find.

  2. Another thing. I tried make a game start and a game over screen. I used Jesse Freeman's logic, so my main.js has StartScreen and GameOverScreen, both GameExtended. They look terrible :(
    it scaled my images so much that I can see only a bit of them. I believe it's not the best way of doing them, because I tried to see how Bio Fleet Title screen was made and I noticed it's a complete different approach.

  3. Another thing. My hero has the power to fly. After flying he can't stop. I believe it's because of acceleration. Can I make it stop, in the air, right after I release the button?
    It keeps moving a little bit after I release it.

That's it for now. Thank you guys!

@leoportilho

  1. usually for shoot where you point, you want the shootLocationMinPctX/Y and shootLocationMaxPctX/Y properties. Check out how it is done in the jump n run grenade launcher: https://github.com/collinhover/impactplusplus/blob/master/examples/jumpnrun/lib/game/abilities/grenade-launcher.js#L45-L49

  2. Try jumpSteps also: https://github.com/collinhover/impactplusplus/blob/master/lib/plusplus/abstractities/character.js#L210

  3. For game start and game over, I think some people like Jesse and Dominic make separate game instances, but I find it simpler to just make them into levels. For game start screen, just set up an event listener for any button press or mouse click, then start the game, and give the player control of their character. Or alternatively, do the same but wait for a UI button to be clicked.

  4. Make sure you set the frictionUngrounded property to very high values if you want him to stop immediately: https://github.com/collinhover/impactplusplus/blob/master/lib/plusplus/abstractities/character.js#L166