Sprite-aligned rotation problem

For questions about using Classic.

Post » Mon Dec 19, 2011 1:26 pm

I'm trying to create a system, where a bunch of equally-spaced "Line" sprites keep their distance to a "Player" sprite and constantly face it, except when the "Player" moves forward/backward relative to its heading - then the distance will increase/decrease.

I have a system working, using 0,0 as a reference point by which all the distance data is calculated... Problem is it only works in the 0-90 degrees range of "Player" angle.

I believe that I need to flip the reference point horizontaly/verticaly/both based on the "Player" angle, but as to how eludes me.

Here's a zipped .cap file is anyone would be willing to help out - much appreciated.

The data for the "Line" spacing and the maximum distance a "Line" can be at before being put back at the beginning of the sequence is inside the Data text object as a private variable. Each "Line" also has a Distance variable which stores the distance for the current loop, for final position calculation.

http://www.sendspace.com/file/c2el80

As a footnote, I had a second system for achieving the same result which used a delta of previous and current "Player" positions to calculate the distance change, but I ran into precision problems - so I hope to use this approach, with your input.

Thanks.
B
8
S
2
G
2
Posts: 85
Reputation: 1,218

Post » Mon Dec 19, 2011 8:50 pm

Is this the effect you were looking for? I used a slightly different approach.
http://dl.dropbox.com/u/5426011/fixed/Funky%20Koval.cap
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Tue Dec 20, 2011 12:31 pm

Thank you. Yes, this is exactly what I'm after.

And this method is similar to the alternative one I wrote...
Now I see that the "precision" problems I had weren't really related to accuracy - unlike you, I was calculating the distance without regard to the "Player" heading, which was throwing my results off.

Again, thank you.
B
8
S
2
G
2
Posts: 85
Reputation: 1,218


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests