setting animation frame to specific angle

This forum is currently in read-only mode.
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • hi guys.

    my racing game is coming along pretty nicely, i have the base gameplay so that i can adjust stuff easily, and im overall pleased. BUT (yeah you knew it was coming lol)

    i started thinking about artistic stuff and presentation. started toying with the idea of trying to make the perspective isometric. i could very well use the existing handling that ive made using the physics object(the actual car sprite is just set on the physics object every tick/always), but the car sprite's presentation would need some work,if its not top down view,but isometric.

    so i ask you wise people, is it possible to to set animation frame to a specific angle?

    for example, if i was to use 360 frames (oh god i really wouldnt, dont be alarmed) for my car's angles, how would it be done? meaning frame 0 is angle 0 and frame 359 is angle 359. i wouldnt want to make actions for every separate angle even if i used less frames, im sure theres simpler, easier way, eh?

    am i too far off if i guess its somehow done by clamping? though i dont really know the correct action or event for it <img src="smileys/smiley5.gif" border="0" align="middle" />

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • In your example, if you'd like to set the frame according to the sprite's angle, it's just

    + Always

    -> Sprite Set animation frame to round(.Angle)

    If you have less animation frames, let's say 18 (describing a complete circle), it would be

    + Always

    -> Sprite Set animation frame to round(.Angle / 20)

    because 20*18 = 360

    So basically you'd just divide 360 by the number of frames to get the factor by which you need to divide the actual angle.

    f = 360 / numberofframes

    actual framenumber = actual angle / f

  • thanks tulamide! i knew there was a simple way to do this, even i can understand that piece of code lol!.

    i'll try this when i get home, BUT (yeah yeah..)

    once again i started wondering if:

    there was a way to cut the amount of frames in half, so i could use more frames without sacrificing VRAM that much. because, correct me if im wrong, theres the option to mirror the sprite angle when moving the opposite direction..? so, if i had a frameset consisting of angles between 270 and 90 going clockwise, in other words a half circle of frames, i could somehow mirror the car sprite, thus drastically saving VRAM and i could make more frames and get smoother rotation.. but that would need some extra eventing and/or math, no?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)