Change images for an actor rotating through 360
Hi,
I'm really struggling to get my actor to use the correct graphic when rotating through 360 degrees on a fake perspective top-down game I'm making.
I thought I could use the self.rotation atribute in some way to control "if rotation angle is between x and y change image", but there is no "between" variable, only more than, less than, that I can find.
Anyone know any clever ways of doing this? sadly I can't bind the change image to key presses as I'm using the vertical thumbstick.
Maybe I can bind the change image to this in some way?!?
I've searched the forums and some people talk about using Vector to angle in various ways but I can't see how this is any different to using self.rotation.
I'm really struggling to get my actor to use the correct graphic when rotating through 360 degrees on a fake perspective top-down game I'm making.
I thought I could use the self.rotation atribute in some way to control "if rotation angle is between x and y change image", but there is no "between" variable, only more than, less than, that I can find.
Anyone know any clever ways of doing this? sadly I can't bind the change image to key presses as I'm using the vertical thumbstick.
Maybe I can bind the change image to this in some way?!?
I've searched the forums and some people talk about using Vector to angle in various ways but I can't see how this is any different to using self.rotation.
Best Answer
-
SoldierBulls Posts: 61
For example, 4 images (up, right, left, down)
RULE 1
Check "All Conditions"
if self.rotation>45
if self.rotation<135
Change Self.Image = "UpImage.jpg"
END OF RULE
RULE 2
Check "All Conditions"
if self.rotation>135
if self.rotation<225
Change Self.Image = "LeftImage.jpg"
END OF RULE
RULE 3
Check "All Conditions"
if self.rotation>225
if self.rotation<315
Change Self.Image = "DownImage.jpg"
END OF RULE
RULE 4
Check "ANY Conditions"
if self.rotation>315
if self.rotation<45
Change Self.Image = "RightImage.jpg"
END OF RULE
Answers
I've tried that, problem with doing "under AND over" (for me anyway) seems to be that other rule conform to the, (e,g, <315) this causes it to stick on certain frames/images.
is this happening maybe because I'm grouping all of the rules inside one timer?
Is this the best way of doing this, I imagine it's a pretty common function, or are there better ways?
now to try and get it working with 16 frames rather than the basic 4 =S
Thanks for your help guys!
self.ImageID = floor(self.Rotation/(360/(self.NumberOfImages-1)))
self.Image = "actorImage"..self.ImageID..".png"
Follow Eating My Hat on Facebook, Twitter and the Blog
Check out my templates in the GS Marketplace or at the store
On the topic of using self.rotation - I did as Mazapy9teen suggested as a test with coloured blocks and it worked great, but then I realized that using self.rotation means the image is always oriented in the direction of travel (obviously - D'oh!), meaning my sprite set will not work as they have fixed orientations (facing: <,/\,>,\/ ). So now I'm really stuck!
I played arond with clamping actor rotation then changing the images using Game.Angle instead of self.rotation, but this comes unstuck when the actor is "nudged" off scene alignment by collisions, and also unless i have a tonne of frames will look like the car is skidding at times as the stick rotation is precise.
So, to clarify what the issues are:
Can now change images by using self.rotation rules, but would love to know how to use EatMyHat's method.
Any ideas how I can make my actor change image relative to scene, while perhaps adjusting the angle by a few degrees if the actor is either nudged, or the stick is between e.g. 22.5 and 45 degrees.
Really wishing I'd just made my racer either top-down or not use a joystick now!