, being a combination of the 名詞（めいし） (noun) つもり ‘intention’, and the 格助詞（かくじょし） (case-marking particle) で ‘with’, this structure is used in several different ways, depending on what comes before it. When combined with verbs, な-Adjectives or nouns in their plain forms, it implies that (A) is being done with the intention of (B).
As つもり is a noun, の will be required before it when grouped with other nouns, while な will be required when linked to な-Adjectives.
I went to the newly built shopping mall without any intention of buying anything, but I ended up purchasing various things.
I bought this fish intending for it to be fresh, but when I took it out of the package, it smelled unbelievably bad.
Despite saying it thinking that it was going to be funny, I ended up hurting their feelings.
However, when paired with verbs in the past form, つもりで
implies that the speaker is ‘acting as though (A)’, ‘pretending that (A)’, or ‘is convinced that (A)’.
Next, try reading it as if you were the main character.
At a party, I danced in front of everybody, as if I was a dancer.
This meaning simply comes from the intention of something being contrary to what is actually true.