This is a bit code i'm having trouble with:
int pressedKey = event.getNativeKeyCode();
for (int i=0; i <= AllTriggerPads.size() ;i++) {
if (AllTriggerPads[i]->get_key() == pressedKey){
AllTriggerPads[i]->mBufferPlayerNode->start();
}
}
the get_key()
is getting a EXC_BAD_ACCESS (Code=1, ...)
Error.
I seem to have a referencing problem. I am using almost the same code in the mouseDown and the fileDrop function:
for (int i=0; i < AllTriggerPads.size() ; i++) {
if (AllTriggerPads[i]->mRect.contains(event.getPos())) {
AllTriggerPads[i]->mBufferPlayerNode->start();
}
}
This works fine!
Sooooo, i guess i am using the AllTriggerPads vector (of obj pointers) not correctly. So I CAN use AllTriggerPads[i]->mRect.contains(event.getPos())
but I CANT use AllTriggerPads[i]->get_key()
. And I CANT access the value itself by AllTriggerPads[i]->key
I have tried it with AllTriggerPads.at(i)
but then i get an out of range error which makes me wonder even more.
The AlltriggerPads was initialized with
vector<TriggerPad*> AllTriggerPads;
So how can I access the key member?