Turning Character depending on mouse location

00george

  • Posts: 161
Hello In my game my character turns depending on the mouse location. You can see this by going to this link http://www.stencyl.com/game/play/11388. But I am having trouble adding the other turning directions also I don't think my method is very practicle. So you anyone could suggest how I could add the other directions I would be grateful. There are screenshots on how I am doing this below.


SuperMario2207

  • Posts: 101
I'm not sure I think you've done it the right way, try using otherwise if instead of the last two if's.
:|        :\
:/        :]                             
:}        :)
:D       =D
XD     <XD

00george

  • Posts: 161
Those 3 work but im not sure how to add the other directions like beheind and that.

Sunflower

  • Posts: 591
Well, there are two ways to do it.

You can rotate the one sprite depending on the mouse rotation, and with such solution it'll be perfectly possible to make 360 degrees rotation with only one sprite. However, I'm not sure if that's what you want, since from the pictures it's very apparent that they don't use the same sprite.

The other way is to make multiple animations, like you had done already, and switch between them depending on the angle from Actor towards mouse coordinates, but this would require drawing more sprites. If they're not animated, you can very well switch between frames instead.

I can make you behaviors for both, though please specify which one do you exactly need. If you choose the second one, please tell me whether sprites are animated or not (so they are actually single images).

00george

  • Posts: 161
Um I know this is alot to ask but could you make both so I could see what I liked more? If not could you just do the second one also the sprites are not animated. Thank you so much.

Sunflower

  • Posts: 591
Published as "00greg rotation", because I'm baka and I can't even write your nick correctly.

Apart from that, you have example actors there. You can make a test scene and insert a few of them to check how it works for both options.

00george

  • Posts: 161
THanks so much. The frame rotation was just what I need it is perfect. I have one last thing to ask would you mind explaining how it works?

« Last Edit: March 04, 2012, 06:57:30 am by 00george »