How do I create advanced controls+animations?

Get help using Construct 2

Post » Sat Jun 28, 2014 9:59 pm

Wow, thanks so much for the help, OddConfection! I tried changing sprite animations based on mouse/player angle relation as you suggested and it works like a charm.

Quick newbie question, though: in your event code example, is aim_angle referring to an instance variable? At the moment I have my sprite changing animation based on a simple though possibly inefficient use of System > Is Between Values > angle(Player.X,Player.Y,Mouse.X,Mouse.Y) and setting the angles as the upper and lower bounds (repeated 4 times for 4-directional movement in my case). Your method seems to be doing just that but in fewer events. I guess I need to get used to reading event shorthand as I'm still pretty much a newb...

Thank you again for the help! And good luck to Everade on his project. :D
B
14
S
6
G
4
Posts: 2
Reputation: 3,261

Post » Sun Jun 29, 2014 10:26 am

Everade wrote:I know what you mean, i've handled this issue already before by simply adding the actual animation sprite on top of the player itself.
So the player is set to invisible.
And rather than pinning the animation sprite to the player, i have set it's position to player every tick.
i'm just not sure if that's such a good idea as in performance perspective.

But thanks a lot for your help!


You're welcome :)

Pinning and setting the position every tick are pretty much equivalent, just one is handled by events and one by behaviour, but there shouldn't be any performance issues.

Using an invisible player sprite is often recommended e.g. for use with the Platform behaviour for colliding with platforms, the only issue I can think of with that using 8 Direction movement is the invisible object is rotating and so is it's collision box which might cause the player to get stuck on things.

@Vespyr
You're welcome too :) I'm glad the method worked for you as well

In the code I posted, aim_angle is a Global variable but you could use an instance variable e.g. Player.aim_angle, which might be useful in a multiplayer game instead of having global variables for each player.

Good luck to you both with your games.
Vote for all the Construct 2 games on Steam Greenlight - Find them here
B
32
S
9
G
7
Posts: 444
Reputation: 6,731

Post » Sun Jun 29, 2014 4:39 pm

Image


Currently the game looks like shown at the bottom.
As you can see, the "Peer" (star) is set to invisible.
Peer angle always looks into cursor direction, and bullets are spawned on Peer angle so they fly into the direction you're aiming.

The Character Sprite "animated" is simply set to position "Peer" every tick.
They look into the direction the cursor is aiming as shown in the Events at the top.
Image
B
39
S
8
G
3
Posts: 158
Reputation: 2,995

Post » Mon Jun 30, 2014 8:06 pm

Image

I really need some help.
I was brainstorming like hell and cleaned up the whole events, in my point of view my solution should be really simple with just these few events.
As you can see in the picture here, i have cleaned up the events to display my character animation.

Everything works as expected.
Unless the Event at the very bottom.

"If Moving, Start Animation"


Could someone tell me what's wrong about it?
I really can't tell...
B
39
S
8
G
3
Posts: 158
Reputation: 2,995

Post » Fri Jul 04, 2014 10:39 am

Is there anyone who could help me with my last post above?
I really can't figure out why the animation does not start to move.

I've also replaced "system repeat 1 times" with "system trigger ones while true"
Still, the animation never starts at all.
B
39
S
8
G
3
Posts: 158
Reputation: 2,995

Post » Fri Jul 04, 2014 10:55 am

The event "Peer: 8Direction is moving: Sprite Start animation from current frame" executes about 60 times a second. So, quicker than you can see the animation start, it will start again, from the same frame. So nothing appears to change.

see the capx
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sat Jul 05, 2014 4:38 pm

Awesome, thanks for the help!
It works now properly :)

However now i'm stuck on a missing condition.
I can't seem to set an animation to property Ping-Pong (reverse the animation) by EVENT!
Mirror or flipping won't work. I require to simply reverse the animation.

Does it even exist ? o.o
B
39
S
8
G
3
Posts: 158
Reputation: 2,995

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests