How do I transform sprites?

Just started using Construct 2? Post your questions here

Post » Sun Feb 28, 2016 11:38 pm

I have a character that swings a sword when an enemy is in his range (2D, Top Down). I realize this with the line of sight behavior. Now I want to visualize that swing. I could create a sprite with the exact angle and length as the line of sight but both can change and I want to avoid creating sprites for every possible combination. I think I read somewhere that you can transform sprites so my idea was to create a sprite with straight lines and then set the height of the sprite to the range of the line of sight and then bend it around a point at the middle of the bottom to make the lines circular depending on the cone of view. Is this possible? If yes, how? If no, what would be the best solution to visualize the swing of the sword?
B
5
Posts: 15
Reputation: 255

Post » Mon Feb 29, 2016 2:19 am

From what I am reading. I would say use joints where on event play swing animation at joint. or at Image point what ever works for you.
B
29
S
13
G
10
Posts: 355
Reputation: 8,317

Post » Mon Feb 29, 2016 9:19 am

The swing is no animation. It's just a Sprite pinned to the player with 0 opacity that appears when the player swings and fades out. That is not the problem. The problem is that I want my square Sprite with straight lines to cover exactly the area where the player hits. In Photoshop you can do this with transform -> warp (not really exact though because you can't just set an angle). Imagine a square Sprite with some white and transparent lines and after the transformation it should look like the wifi symbol.
B
5
Posts: 15
Reputation: 255

Post » Mon Feb 29, 2016 9:55 pm

Found another way to do this but I am still curious how other people would realize this.

This is how I did it: I created a white sprite 1 px high and I have one variable for the los range and one for the cone of view. When the player hits an enemy I start a for loop with that counts a variable up by 1 until it matches the cone of view. This for loop creates one of my sprites at the players position and with the angle set to Player.Angle+(coneOfView/2)-count. This creates sprites in the exact angle of the cone of view. I set its length to los range and this creates a cone that matches exactly my cone of view and range of sight. The sprite has the fade behavior set to 0.1 so it just flashes and quickly fades away. Maybe I have to make it higher then 1px for greater angles to minimize the gaps between the created sprites but it should work.
B
5
Posts: 15
Reputation: 255

Post » Tue Mar 01, 2016 5:27 am

Kincaid wrote:Found another way to do this but I am still curious how other people would realize this.

This is how I did it: I created a white sprite 1 px high and I have one variable for the los range and one for the cone of view. When the player hits an enemy I start a for loop with that counts a variable up by 1 until it matches the cone of view. This for loop creates one of my sprites at the players position and with the angle set to Player.Angle+(coneOfView/2)-count. This creates sprites in the exact angle of the cone of view. I set its length to los range and this creates a cone that matches exactly my cone of view and range of sight. The sprite has the fade behavior set to 0.1 so it just flashes and quickly fades away. Maybe I have to make it higher then 1px for greater angles to minimize the gaps between the created sprites but it should work.


sounds solid to me. just don't really understand the difference between that and just playing an animation that would step through the whole thing step by step without all the extra coding. Good luck.
B
29
S
13
G
10
Posts: 355
Reputation: 8,317

Post » Tue Mar 01, 2016 6:50 pm

Maybe I don't understand you right, but there is no animation for the swing. It's just a cone that appears for 0.1 seconds and then fades away. The cone must be the exact size and angle of the cone of view. If you have an easier solution with less lines of code feel free to tell it to me. :)
B
5
Posts: 15
Reputation: 255

Post » Wed Apr 20, 2016 10:29 pm

Sword streak with auto attack: saber_range.capx
ImageImage
B
108
S
49
G
23
Posts: 783
Reputation: 22,611


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest