How do I animate 360

Just started using Construct 2? Post your questions here

Post » Wed Aug 20, 2014 12:51 pm

hello all.

i have a game that uses 3D to 2D images, and now i have a question. how do i animate 360 rotating?

here's an image of what i got:
i.imgur.com/XCuhGyF.png

now, that boat has one animation and that animation is every corner od 360°. Animation is disabled by default and current frame is set to 270 (of 360), so the boat is facing up. now when i press "a" or "d" i want the boat to rotate - > changing frames, not playing animation, while i hold the key.

is there any way to do this easier? possibly without 360 frame animation? i could cut down to 96 frames 4x24 for each quadrant, but still a lot of work to do. i also would have to set on each frame a "firing point" and more...
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
43
S
14
G
12
Posts: 626
Reputation: 9,450

Post » Wed Aug 20, 2014 1:05 pm

You need to add a "Keyboard" plugin on your project.
Use the event "On key down" "d" and add the action "Boat: Set animation frame to (Boat.AnimationFrame + 1) % Boat.AnimationFrameCount" where Boat is the sprite that contains your boat animation.

Use the event "On key down" "a" and add the action "Boat: Set animation frame to Boat.AnimationFrame - 1" and add a subevent "Boat: Animation Frame <0" action "Boat: Set animation frame to Boat.AnimationFrameCount - 1".

This should do what you intend to. At worst, post/attach a current capx to your post to let us help you further.
Be aware international keyboard user won't appreciate the use of the "a" key.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
294
S
117
G
96
Posts: 7,310
Reputation: 71,084

Post » Wed Aug 20, 2014 1:06 pm

Doing it your way would be something like:
give the boat an instance variable: angleframe

a key is down : set boat.angleframe to boat.angleframe-1
d key is down : set boat.angleframe to boat.angleframe+1

system compare two values: boat.angleframe=360 - set boat.angleframe : 0
system compare two values: boat.angleframe=-1 - set boat.angleframe : 359

every tick - boat set frame to: boat.angleframe

Btw instead of making the firing point on every frame why not make an invisible sprite with the imagepoints in the right place and rotate it to the angle of the boat.animationframe?

It would actually be far wiser to rotate your boatsprite itself instead of having animation for each angle..
You could have a few frames to give the impression of 3D but this seems like overkill..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Aug 20, 2014 1:33 pm

@kyatric - i will try that. i used to do it with instance variable like littleStain said it, but it seemed overly complex for that. about the keyboard - i know that i need that object, and i've created a "main menu", where you can bind keys as you like :) - i will post the game here once it's done. since i'm not doing this one commercially, just for showcase and stuff :)

@littleStain - i think i will use kyatric's method for that. but i have a question for shooting. i mean, firing point. why do you think i should use another inivisible sprite? couldn't i use imagepoints on the same boat sprite, and rotate it with boat? though i have tried something like that before, but i think that point doesn't move as boat does. example: default like on image - if i put on top of the boat iamgepoint, it will fire from it's nose, if i rotate.. let's say 45° left, it will fire from under the ship, because point moves wierd and boat gets longer from rotating.

also, if i rotate 1 sprite without animation, it looks wierd, like upside down boat: here you go:
i.imgur.com/EmKWZ4a.png
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
43
S
14
G
12
Posts: 626
Reputation: 9,450

Post » Wed Aug 20, 2014 3:22 pm

Yes you could set an imagepoint for each animationframe, which would mean setting it 360 times, or set it once on an invisible sprite..
The effect would be basically the same (as in noone would notice) and it woulf be a lot less work..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Aug 20, 2014 7:05 pm

but why on an invisible sprite? i can use boats sprite, no?
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
43
S
14
G
12
Posts: 626
Reputation: 9,450

Post » Wed Aug 20, 2014 7:31 pm

Just do it your way 360 times, instead of 1..
Good luck.. :)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest