Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
September 06, 2026 - @937.25
Activity rating: Four Stars Posts & Arts: 62/1k.beats ~ Boop! The forum will close in 63.beats! Random | Recent Posts | Guild Recents
News: There's a great big indie web tomorrow! :smile: Guild Events: 10: window

+  MelonLand Forum
|-+  Life & The Web
| |-+  ✁ ∙ 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 55 times)
oro_junestar
Casual Poster ⚓︎
*
View Profile WWWArt


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

Guild Memberships:
Artifacts:
Great Posts PacmanJoined 2026!
« on: Today at @15.41 » 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: artifact guyBlue ham-ham rangerstar cutieGay NeurodivergentBugbooooCherryQurbyAwful Posts Pacmansuck itGaryLazy (part1)Lazy (part2)Yarn kittyVillager 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: Today at @614.50 » 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: Today at @618.04 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 MelonLand Editor Recent Edits Tenement Arcade Want to Login or Join ? Forum Art Hub Chat Webring Web Guides Graphics Catalogue Wiki Newsletters Image Stream
Melon's Sites TamaNotchi Textures PixelSea GifyPet MoMG Ozwomp Online Loom Videos Leaky Webring Melonking
Tools Melon Software ArtHub Embed Maker ML Passports
Outlinks Frutiger Aero Forum Onio Club m15o's Web Services 32Bit Cafe iMood Webrings Internet Phone Book HTML Energy Declarations Hackers & Designers
Zap!
Minecraft: Online
Join: craft.melonking.net