Yet another error


image
i have no idea why this isnt working since stephen never defined that function in the cpp for enemy and it worked for him.

What is the specific error you are getting? It helps to start there.

'no matching function for call to ‘Enemy::getCollisionRec()’
‘too few arguements in function call’

and because of this error. the enemy on the screen has disappeared.

That error makes sense, based on your declaration for getCollisionRec you’re expecting an argument of type Vector2 to be passed in when you call the function.

I imagine this isn’t what you wanted, so you’ll need to remove that argument in both the declaration and definition for that function.

(PS - I’m responding late at night so I could have missed something)

no problem, just glad for a response to help with this. but ,well thats the thing, stephen never defined the get collision rec. in the video at 6:39 were in the enemy cpp. and enemies get collision rec is not defined. but it works? im just confused on why its messing up for me, but didnt for him. and thats the only error im getting. that 1 collision rec

Just to confirm, do you have a declaration for getCollisionRec inside of the BaseCharacter class? That would explain your confusion. If so, you would need to remove the declaration within your Enemy class.

no, there is no Enemy::getcollisionrec() only basecharacter::getcollisionrec(), we never got to the point of defining the enemies collision rectangle like we did in base character or with the props part. which makes me think it needs to be defined. but in the video he does not have it defined and never tells us, or goes through it with us.

You wouldn’t need to if basecharacter::getcollisionrec() is already defined. Since the Enemy class is a child class of BaseCharacter (and assuming the function is not private), then Enemy inherits that function from BaseCharacter.

There would be no need to define it again in the Enemy class. Can you show me your implementation of BaseCharacter? Just the header file is fine.

well after a week of being stuck on the exact same line - ive managed to mess it up so bad just trying to understand where i went wrong - ive messed it up beyond repair i guess. now anytime i go to any page, and try to start debugging, it says the file doesnt exist.

now, ive gone back 4 videos, and the man NEVER defines get collision rec. i even went onto the next video to see if that helps. he still, never defines the function of “getCollisionRec()” for the enemy.

in the base character header file, its declared as
Rectangle getCollisionRec();

in the enemy header file its declared as
Rectangle getCollisionRec(Vector2 Goblin);

and in the props header
Rectangle getCollisionRec(Vector2 knightPos);

props on the other hand, DOES indeed define it
Rectangle Prop::getCollisionRec(Vector2 knightPos)

{

Vector2 screenPos{ Vector2Subtract(worldPos, knightPos) };

return Rectangle{

    screenPos.x,

    screenPos.y,

    texture.width * scale,

    texture.height * scale

};

}

which brings me back to my whole point, why is it working for him and not for me? if its going off of the ‘base character values’ shouldnt it be fine using the line that is errored? at this point im kinda tired of bashing my head against this wall.

If you take a look at the header for the enemy at this lecture, you’ll see there is no declaration for any additional version of getCollisionRec() declared and that the function is declared in the BaseCharacter class that Enemy inherits from.

I imagine the reason you’re getting the error (without seeing the exact wording of the error myself) is that the compiler is confused on what declaration to use (it probably shouldn’t, but that’s a different matter).

yea i remember you saying something at some point about sometimes its just the compilers fault, but as a new guy idk. im just gonna have to delete this entire thing and start back over from the beginning, cause like i said, now, it wont even load anything

It would also be useful for me to point out that squiggles don’t always go away until you build your project in VSCode.

i also used build run task or run build task, i forgot the order, but it still didnt make the error go away. the only other thing i could do is plaster this post with images of every single page and line. which, i feel is too much. and as much as i dont want to ill just restart the entire section this weekend. thanks for your help tho. wish i had a buddy like you lol

Sometimes it’s good to take a step (or two) back and redo things. I do that quite a lot when I’m trying to learn something new.

yea but my whole problem with this tutorial is the wording he uses on some of the stuff…for example. knight pos, screen pos, world pos…just type out position. we can come up with shorter lingo when were more comfy with coding. but with my learning curve. in my brain. its not even considered “screen position” cause were not talking about the screen position, were talking about the characters position ON the screen. its just so confusing. or a few videos back when he talked about classes for the first time, gave a class called barbarian and put damage as a variable…in my mind, that was a horrible example, cause in my mind damage is not the same every single strike. level, health, mana, strength, those are the types of variables that pop into my head - im just different. idk. there was several times in school when i had to ask the teachers questions about the work cause i didnt understand…starting to think i need that here as well. 1 on 1 talking about issues

also, dont get me wrong, dude is doing a GREAT job on the tutorial. i just need things to be put into laymans terms i guess.

That’s what I’m here for! If you need additional explanations for things I’ll do what I can.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms