pygame:在NPC对话中分隔文本

时间:2018-11-26 13:21:46

标签: pygame

我想在2D平台游戏中与NPC建立对话。问题是,文本在屏幕上彼此重叠。因此,我想像这样,当您按空格/输入键时,下一个文本对话框应该出现,而上一个文本应该从屏幕上消失。我还希望有一个文本背景和边框,所以它看起来真的像文本气球。

这是我的代码:

        if self.sidequest1_completed == 0:
        if self.sidequest1_started == 0:
            hits3 = pg.sprite.spritecollide(self.player, self.npc, False);
            if hits3:
                self.player.vel.x= 0;




                self.draw_text("Can you help me", 12, BLACK, WIDTH/2, (HEIGHT/1.5)+1)
                self.draw_text("all my flowers are gone!", 12, BLACK, WIDTH/2, (HEIGHT/1.5)+12);
                self.draw_text("can you find them for me?", 12, BLACK, WIDTH/2, (HEIGHT/1.5)+24);
                pg.display.flip();
                 #print('button pressed');
                self.press_space();
                pg.display.flip();
                self.player.vel.x= 0;
                self.draw_text("if you find them all.", 12, BLACK, WIDTH/2, HEIGHT/1.5);
                self.draw_text("i'll let you go", 12, BLACK, WIDTH/2, (HEIGHT/1.5)+12);
                self.draw_text("through my shroom to the other side.", 12, BLACK, WIDTH/2, (HEIGHT/1.5)+24);
                pg.display.flip();
                self.press_space();
                self.player.pos.x = hits3[0].rect.left - 33;
                self.sidequest1_started = 1;
                self.collected = -1;

这是我目前所拥有的东西: Example

任何帮助将不胜感激!抱歉,如果我不够具体。

0 个答案:

没有答案