Change images for an actor rotating through 360

RedCatRedCat Member Posts: 26
edited April 2012 in Working with GS (Mac)
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.

Best Answer

  • SoldierBullsSoldierBulls Posts: 61
    Accepted Answer
    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

  • RedCatRedCat Member Posts: 26
    Thanks guys,

    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?
  • RedCatRedCat Member Posts: 26
    gave this another try using Mazapy9teen numbers. It's working better then I've managed before, so BIG thanks for that, but the right image >315 <45 is not working... however if I do one rule for >315 and a seperate one for <45 it works!? guss it goesn't like crossing the 0/360 line

    now to try and get it working with 16 frames rather than the basic 4 =S

    Thanks for your help guys!


  • SoldierBullsSoldierBulls Member Posts: 61
    REMEMBER to check ANY CONDITION only in the 4th rule! :) Then the right image will work! ;)
  • RedCatRedCat Member Posts: 26
    Got you, thanks again!!
  • EatingMyHatEatingMyHat Member Posts: 1,246
    edited April 2012
    @RedCat You don't have to use rules at all... if you number your images from 0 to your number of images, you can apply the following logic:

    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
  • RedCatRedCat Member Posts: 26
    Hi EatingMyHat. I've heard using IDs suggested on a few forum posts, but tbh I'm really not sure how to set them up in GS. Also, rather than simply copy>paste I'm curious - what does "floor" do?

    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!

  • RedCatRedCat Member Posts: 26
    p.s I've tried just rotating the images so the front of the car always faces up but this looks like arse and is going to be very labor intensive for all frames of all actors.
Sign In or Register to comment.