Logo

Animating a sprite using the songs BPM on the Music Wheel

Register Log In Back To Forums

Post #1 · Posted at 2016-08-18 08:45:59am 7.5 years ago

Offline leadbman
leadbman Avatar Member
263 Posts
Australia
Reg. 2016-02-01

"Working On: 5thMix BGA bgchanges"
Hi all,

I've been working on a theme and I need some advice, I want to animate a sprite using the BPM from the currently highlighted song on the music wheel.

Here's my sprite animation code:

t[#t+1] = Def.Sprite {
Condition=GAMESTATE:IsCourseMode() == false;
Condition=GAMESTATE:IsSideJoined(PLAYER_1) == true;
Texture="_sprite1 4x8.png",
InitCommand=function(self)
self:diffusealpha(0.5):zoom(1):vertalign(bottom):Center():xy(_screen.cx-350, _screen.cy+97)
self:SetAllStateDelays(0.0516)
end,
OnCommand=function(self)
--self:sleep(999):linear(1):diffusealpha(0)
end
};

t[#t+1] = Def.Sprite {
Condition=GAMESTATE:IsCourseMode() == false;
Condition=GAMESTATE:IsSideJoined(PLAYER_2) == true;
Texture="_sprite2 4x8.png",
InitCommand=function(self)
self:diffusealpha(0.5):zoom(1):vertalign(bottom):Center():xy(_screen.cx+350, _screen.cy+97)
self:SetAllStateDelays(0.0516)
end,
OnCommand=function(self)
--self:sleep(999):linear(1):diffusealpha(0)
end
};


I'd like to animate them "in time" with the music. I've worked out that I'd need to alter the "SetAllStateDelays" to do it but I'd need most of the values for that to be lower than 1 as 1 is too slow.

From what I've read I think I need to do something with GetSongBeat() but I'm not sure.

Any insight would be greatly appreciated, I've seen other themes animate things to the BPM (even the default SM5 theme animates the header to the BPM) - but I've only ever seen instances where it just zooms or changes the velocity of the object, not directly affecting a sprite animation.

Hope someone can help!
https://zenius-i-vanisher.com/ddrsig/18213.png?t=1510895050
Really need to add my scores to the tracker soon.
Always learning, always trying to push the boundaries of SM.

Post #2 · Posted at 2016-08-20 02:09:31am 7.5 years ago

Post #3 · Posted at 2016-08-24 04:06:53pm 7.5 years ago

Offline leadbman
leadbman Avatar Member
263 Posts
Australia
Reg. 2016-02-01

"Working On: 5thMix BGA bgchanges"
Thanks for that. I ended up using "effectclock" to get the animation going in sync with the music. I had to change the state delays offset to a bit higher to get the desired result but it's working fantastically now! Hope this will help someone.

t[#t+1] = Def.Sprite {
Condition=GAMESTATE:IsCourseMode() == false;
Condition=GAMESTATE:IsSideJoined(PLAYER_1) == true;
Texture="_sprite 4x8.png",
InitCommand=function(self)
self:diffusealpha(0.5):zoom(1):vertalign(bottom):Center():xy(_screen.cx-350, _screen.cy+97):effectclock('beatnooffset')
local song = GAMESTATE:GetCurrentSong()
local getbeat = GAMESTATE:GetSongBeat()
local getbeatdown = (getbeat/60)/10
self:SetAllStateDelays(0.1200)
end,
OnCommand=function(self)
--self:sleep(999):linear(1):diffusealpha(0)
end
};

https://zenius-i-vanisher.com/ddrsig/18213.png?t=1510895050
Really need to add my scores to the tracker soon.
Always learning, always trying to push the boundaries of SM.
Register Log In Back To Forums

0 User(s) Viewing This Thread (Past 15 Minutes)

©2006-2024 Zenius -I- vanisher.com -5th style- IIPrivacy Policy
Web Server: 4% · Database: 4% · Server Time: 2024-03-19 09:19:03
This page took 0.004 seconds to execute.
Theme: starlight · Language: englishuk
Reset Theme & Language