A new question about character selection (Solved)

0 favourites
  • 7 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • There have been a lot of questions about character selection screens, but nothing that I can find about actually implementing multiple character choices in a game...

    Here is a copy of the capx I am working with, and you can see that in the "Menu" group, the player selects a character, but each character has 4 or 5 different animations, and aside from creating each of the four characters as their own sprite with four copies of all of the events

    For example:

    -mob collides with playerbox

    +player set animation to "ouch"

    would have to tell all four character sprites to animate "ouch", wouldn't it?

    How can I actually go about implementing multiple characters?

    Thanks so much :)

  • Probably the best way to do it is this:

    You should already have an object "player" which is an invisible rectangle, and the "player_image" animations are stuck on top of that. If you don't have this, do it now, as it will save you a collision headache in the future.

    Once you have done this, simply add and rename all of the animations in the player_image so you have something like this:

    1_run

    1_attack

    1_walk

    1_jump

    Then you can just add the corresponding other character's animations in the same format.

    2_run

    2_attack

    2_walk

    2_jump

    3_run

    3_attack

    3_walk

    3_jump

    etc.

    Then, you should have a global variable called 'character' or something which will always be the number your character is at the moment.

    Then, in your animations, instead of doing

    set animation to: "run"

    you can just

    set animation to: character & "_run"

    And that should work nicely.

  • And what if the characters have different animations, so the hitboxes would be different?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can always resize the invisible rectangle. Seriously, however, it is extremely important to have the invisible rectangle, unless you fancy yourself getting stuck in walls...

  • Probably the best way to do it is this:

    Oh my gosh, I was so close. Hahaha. If you look at the capx, I'm already doing the exact same thing in the menu events, it just never clicked that I could do that for animations. :) Thanks sqiddster. Also, as per the platform tutorial I am already using invisible player rectangles.

    Once again, I love you C2 forums. :)

    Edit: They should put this post in the sticky. I searched for ages, and it's such a simple/powerful demonstration of using variables in expressions. May be useful to other people jsut starting out in programming.

  • I am running into some trouble with the method described. I think it's a pretty simple syntax mistake on my part, but I have two players, and each one is a different instance of the "player" sprite, with their respective "player_images" instance pinned on top. The problem I have is picking the proper player_images when an instance of "player" is picked. I gave them both an instance variable, "player" which is either 1 or 2, but when player 1 runs into a mob, both player_images still flash.

    Is there a simple way to give a particular instance of an object a preference for the player_images with the player instance variable which is the same as its own?

    Here's the capx.

    dl.dropbox.com/u/11790413/Final_Project.capx

    Edit: Wait, I think I figured it out. lmao

    This is what i did in pseudocode

    • is condition

    + is action

    -Player on collision with mob

    -Player_Images.player = Player.player

        +actions go here

    Seems to work ok. :)

  • Glad I helped :D

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)