Changing Colors Throughout the Trial


Author
Message
krmanning10
krmanning10
New Member (26 reputation)New Member (26 reputation)New Member (26 reputation)New Member (26 reputation)New Member (26 reputation)New Member (26 reputation)New Member (26 reputation)New Member (26 reputation)New Member (26 reputation)
Group: Forum Members
Posts: 10, Visits: 20
Hello,

How can I have these rectangles change from black to blue at certain time points in the trial without the participant input of the space bar resetting the colors back?

The relevant code:

<trial synchrony>
/ onTrialBegin = {
  // we start out playing no note, skipping all of them
  sound.noteA.skip = true;
  sound.noteC.skip = true;
  sound.noteD.skip = true;
  sound.noteE.skip = true;
  sound.noteF.skip = true;
  sound.noteG.skip = true;
  // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31
    //if (values.xAtResponse < 15pct)
  if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct)
  sound.noteC.skip = false
    if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)
    sound.noteC.skip = false;
  // if over line 3, 4, or 7 we enable note G
  if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct)
    sound.noteG.skip = false;
    if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct)
    sound.noteG.skip = false;
  // if over line 5 or 6, we enable note A
  if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct)
    sound.noteA.skip = false;
    if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)
  sound.noteA.skip = false;
    if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)
  sound.noteG.skip = false;
    if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct)
    shape.line1p2.color = green;
    if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)
    shape.line2p2.color = green;
    if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct)
    shape.line3p2.color = green;
    if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct)
    shape.line4p2.color = green;
    if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct)
    shape.line5p2.color = green;
    if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)
    shape.line6p2.color = green;
    if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)
    shape.line7p2.color = green;
    //confederate
    if (trial.synchrony.elapsedTime >= 5)
    shape.line1p1.color = cornflowerBlue;
    if (trial.synchrony.elapsedTime >= 10)
    shape.line2p1.color = cornflowerBlue;
    if (trial.synchrony.elapsedTime >= 15)
    shape.line3p1.color = cornflowerBlue;
    if (trial.synchrony.elapsedTime >= 20)
    shape.line4p1.color = cornflowerBlue;
    if (trial.synchrony.elapsedTime >= 25)
    shape.line5p1.color = cornflowerBlue;
    if (trial.synchrony.elapsedTime >= 30)
    shape.line6p1.color = cornflowerBlue;
    if (trial.synchrony.elapsedTime >= 35)
    shape.line7p1.color = cornflowerBlue;
  }
/ stimulusTimes = [1=clearScreen, Participant_Avatar, Confederate_Avatar, musicline, line1p1, line1p2, line2p1, line2p2, line3p1, line3p2, line4p1, line4p2, line5p1, line5p2, line6p1, line6p2, line7p1, line7p2,
  noteA, noteC, noteD, noteE, noteF, noteG, debug, confederatename, participantname; 1000 = line1p1BLUE; 2000 = line2p1BLUE; 3000 = line3p1BLUE; 4000 = line4p1BLUE; 5000 = line5p1BLUE; 6000 = line6p1BLUE; 7000 = line7p1BLUE]
/ beginResponseTime = -1
/ validResponse = (" ")
/ recordData = true
/ isValidResponse = {
  if (trial.synchrony.response== 57)
   values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
   values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration
   values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
        return true;
  }
// onTrialEnd = {
//  if (values.musicLineDuration <= 0 || trial.synchrony.response == 0) // if trial times out, we reset everything
//   values.musicLineStartX = 5%; // back to the original start position
   //values.musicLineDuration = 7250; // back to original duration
        //values.xAtResponse = 0%; // we don't have any response yet
//   values.repCount += 1; // we increase the repetition count
//  }
/ branch = {
    if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) // as long as animation / trial hasn't timed out, we keep running
        return trial.synchrony;
}
/ timeout = values.musicLineDuration
</trial>
Attachments
experiment.iqjs (2 views, 273.00 KB)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View

Reading This Topic

Explore
Messages
Mentions
Search