How do I translate, "by pretending that something is real?"
通过假装...是真的的方式

By pretending the dinner is real, Peter and his friends forgot about hunger.
通过假装晚餐是真的的方式， 潘和他的朋友们忘掉了饥饿。

Or you can take a little liberty:

通过假装用晚餐的方式， 潘和他的朋友们忘掉了饥饿。