I’m completely new to oF and coding in general. I’m having a hard time figuring out these errors. I’m doing a version of text rain, but allowing real time text input and mapping each letter to a sound.
The errors are only in the draw section in pink below.
If anyone can help me out, I’d greatly appreciate it. If you need the all the code, please let me know and I will post. Thanks so much in advance!
void testApp::draw(){
//for drawing beat colored letters
char tempStr[255];
//------------------draw letters
ofSetColor(0xffffff);
grayDiff.draw(0,0);
//display runtime info for debugging
ofSetColor(0xff0000);
ofDrawBitmapString("fps: "+ofToString(ofGetFrameRate()), 10, 10);
ofDrawBitmapString("threshold: "+ofToString(threshold), 10, 20);
//advance the location of each character of the string
int i;
for (i = 0; i<str.length(); i++) {
int max;
if (arrayFilled) max = 100;
else max = currLetter;
for (int i=0; i < max; i++) {
//New positions
x[i] = priorX;
y[i] = y[i]+5;
if (y[i]>480) {
y[i]=0;
}
//Draw the character, get its outline
// draw in green
ofFill();
theFont.drawStringAsShapes(letters[i],x[i],y[i]);
error: invalid conversion from ‘char’ to ‘const char*’
error: initializing argument 1 of ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits, _Alloc = std::allocator]’
ofRectangle theRect = theFont.getStringBoundingBox(letters[i],x[i],y[i]);
error: invalid conversion from ‘char’ to ‘const char*’
error: initializing argument 1 of ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits, _Alloc = std::allocator]’
ofNoFill();
// if colliding with something, backup you are not colliding.
// must be a better approach here that can still avoid jitter.
while (grayDiff.countNonZeroInRegion(theRect.x,theRect.y,theRect.width,theRect.height)>0) {
ofSetColor(255,0,0); //red
theRect.y = theRect.y -1;
y[i] = y[i] - 1;
// play a sound
if (letters[i] == ‘a’){ // do somehing
beatdistorted1.play();
} else if (letters[i] == ‘b’) {
beatdistorted2.play();
} else if (letters[i] == ‘c’) {
beatdistorted3.play();
} else if (letters[i] == ‘d’) {
beatdistorted4.play();
}
break;
if (y[i]<0) {
y[i]=0;
break;
}
}
if (theRect.width>10) {
priorX = priorX + theRect.width;
} else {
priorX = priorX + 10;
ofSetColor(0, 191, 255); //deep sky blue
}
}
// start drawing characters 10 in from the side
priorX = 10;
}
}