Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
Autumn, 20 Oct 2026 - @93.43
Forum Activity: Two Stars Random | Recent Posts | Guild Recents
News: :sleep: These are fast times on the World Wide Web~ Guild Events: MelonLand's Seasonal RPG Jam
Super News: ~~MelonLand's Halloween Profile Design Contest 2026~~
+  MelonLand Forum
|-+  Da Web Revival
| |-+  ✁ ∙ Web Crafting
| | |-+  ☔︎ ∙ I need Help!
| | | |-+  How to do frame-by-frame animation with javascript?


« previous next »
Pages: [1] Print Embed
Author Topic: How to do frame-by-frame animation with javascript?  (Read 405 times)
oro_junestar
Jr. Member ⚓︎
**
View Profile WWWArt


I'm the ghost, actually. But yeah, rockage.
⛺︎ My Room

Guild Memberships:
Artifacts:
artifact guystar cutieGreat Posts Pacman3d starJoined 2026!
« on: Autumn, 06 Sep 2026 @015 » Embed

I've got a pretty complicated idea; I want to make an interactable pet window with my cat character, Hope. I've split her into multiple parts to allow for interactions like petting her head, poking her eyes, or swapping her bandana.
This is how she looks on the site:

This is how she's arranged in the code:


My question is, how can I use scripts to move the individual parts to set positions in set timing?

I want to start with a tail wag animation like this:

Logged

Pac-Man! My readings suggest a nearby ghost to rescue! Either that, or I have spaghetti sauce on my monitor.

Artifact Swap: black n lilac yappin kittayblack n lime yappin kittaycuppa joe (#1 :3)Blue ham-ham rangerGay NeurodivergentIchifactCatCherryQurbysuck itPopsicleGaryLazy (part1)Lazy (part2)Villager Spawn Egg
MediocreMetastasis
Sr. Member ⚓︎
****
View Profile WWWArt


Wishlist Skelecool: Remnants Please!!!
⛺︎ My Room
Itch.io: My Games

Guild Memberships:
Artifacts:
Joined 2025!
« Reply #1 on: Autumn, 06 Sep 2026 @615 » Toggle Font Embed

There are multiple ways I can see you tackling this problem

Theres the <canvas> element. You do need to heavily use js and a bit complicated but you can easily draw images with set positions, this method is basically like rendering game graphics. This option would give you the most freedom.

You can use css animations and interchange them using js
example css animation
/* The animation code */

CSS:
@keyframes tail-wag {
  from {transfrom: rotate(45);}
  to {transform: rotate(-45);}
}

/* The element to apply the animation to */
.tail-wag {
  animation-name: tail-wag;
  animation-duration: 4s;
}
JS:
const tail = document.getElementByID("tail");

// 1. Add the animation
tail.classList.add('tail-wag');

// 2. Remove the animation
tail.classList.remove('tail-wag');

// 3. Toggle it on/off (e.g., on a button click)
tail.classList.toggle('tail-wag');

//May work IDK just throwing stuff at a wall
[close]

Or good old updating the rotation property using a setInterval() function

2nd one seems the easiest

« Last Edit: Autumn, 06 Sep 2026 @618 by MediocreMetastasis » Logged


Artifact Swap: Sad DoggoNeutral Doggo
Pages: [1] Print Embed 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | Send Feedback | Supporters ♥ Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi
@000 Melon
Land
Forum Art Hub Chat Webring Explore Random Recent Tenement Arcade Want to Login or Join ? Web Craft Guide Graphic Catalogue Wiki Help I'm Lost! Link Land Newsletters Image Stream Minecraft: Online
Zap!
Passport Sites tamaNOTchi Asatte Add your site?
Aero Archive Onio Cafe 32 Bit Cafe Status Cafe