This site requires JavaScript, please enable it in your browser!
Greenfoot back
SandDealer
SandDealer wrote ...

2014/3/22

bass kick method help...

SandDealer SandDealer

2014/3/22

#
Is there a way to write a method that will return true or false values depending on the bass kick in a song that is played. I want to make that my objects change pictures based on music... sth like this... boolean bass() if (bass kick) return true; else return false; class object ext Actor greenfootImage pic1 = ....... greenfootImage pic2 = ....... if (bass()) setImage pic1 else setImage pic2 Just give me a clue from where to start, cuz I've got no idea how to make this happen.. I'll be extra happy if someone help me, if not, never mind... :)
SandDealer SandDealer

2014/3/22

#
is this even possible ?
danpost danpost

2014/3/22

#
The only way to do that (that I know of) is to determine how many milliseconds occur between bass kicks and have a timer start at the same time the music starts. Then use the value of the timer to determine when to make the image change. You would use sth like... startTime = System.getCurrentTimeMillis(); // declare startTime field as 'double'; use this when music starts ... // in act method double currentTime = System.getCurrentTimeMillis(); if (getImage() == pic2 && (currentTime()-startTime())%gapTime < 200) setImage(pic1); else if (getImage() == pic1 && (currentTime()-startTime())%gapTime >= 200) setImage(pic2); 'gapTime' should also be declared as a double field; set it to the time between kicks in milliseconds.
SandDealer SandDealer

2014/3/22

#
Yea, I thought of that, but there's a problem that kick's aren't there all the time, and songs are changing on every level.. so there's a lot of job for a tiny detail like this, i'll think again whether I do that or not. Anyway tnx mate.
JasonZhu JasonZhu

2014/3/23

#
I'm just going to point out that your pic is very trippy. It's like its turning. Optical Illusions are messing with my brain.
You need to login to post a reply.