Lambdas can only capture identifiers. You could alias it however.
auto* alias = mySprite;
CallFunc::create([ alias ] () { alias->doSomething(); })
also a reminder that if the sprite could get removed and released before the callfunc’s lambda is executed you will want to protect it with a retain/release
auto* alias = mySprite;
alias->retain();
CallFunc::create([ alias ] () {
alias->doSomething();
alias->release(); // or safe_release
})
See this answer:
The standard states that a capture must be &, =, this, an identifier, or an identifier preceeded by &.
Since this->mySprite is not an identifier, but a “class member access expression”. the compiler is correct when rejecting your snippet.