Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    sprites to screen from button press

    Beginners
    2
    13
    584
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • waldron
      waldron F last edited by

      looking for a way to print a dialog box to the screen.
      e.g
      sign post or npc dialog box in certain positions on a map

      1 Reply Last reply Reply Quote 0
      • pobtastic
        pobtastic F last edited by

        Just create an image, use it as a drawTarget ~ then when it's required to be shown... (populate it) display it after you've rendered everything else.

        It's a bit how I handle my "debug" overlays for Manic Miner/ JSW (although obviously they're transparent).

        waldron 1 Reply Last reply Reply Quote 0
        • waldron
          waldron F @pobtastic last edited by waldron

          @pobtastic draw target location? would that display the sprite when needed

          1 Reply Last reply Reply Quote 0
          • pobtastic
            pobtastic F last edited by pobtastic

            Here's a crude example (it's not a sprite, it's like ... a canvas? You can draw sprites to it if you like);

            // The dimensions of our dialogue box.
            overlay = createImage(128, 128, false, image_rgba)
            
            loop
              clear()
            
              c = controls(0)
            
              // Okay so this isn't very neat but hopefully you get what I mean...
              show_overlay = false
              if c.x then
                show_overlay = true
                paint_overlay()
              endif
            
              // Now ... this is the default draw target, so we switch back to it (and there's no harm in setting it if we're drawing to it anyway).
              setDrawTarget(framebuffer)
            
              for i = 0 to rnd(100) loop
                // Just some nonsense!  Caveat, maybe doesn't work!
                box(
                  rnd(gWidth()),
                  rnd(gHeight()),
                  rnd(gWidth() / 4),
                  rnd(gHeight() / 4),
                  { rnd(255) / 255, rnd(255) / 255, rnd(255) / 255, 1 },
                  false
                )
              repeat
            
              // Obviously you can do this however you like but here I'm just drawing our dialog to the default draw target like it's any regular image (which it is).
              if show_overlay then
                // Untested dimensions!  (If it doesn't work know that I'm just trying to draw to the right-hand side of the display with a little padding).
                drawImage(overlay, (gWidth() - imageW(overlay)) - 100, imageH(overlay) - 50)
              endIf
            
              update()
            repeat
            
            /**
             * Draws our dialog box.
             */
            function paint_overlay()
              setDrawTarget(overlay)
              // As this is a completely separate target, it behaves independently to the framebuffer ~ hence we can clear it!
              clear(yellow)
              ink(black)
              // Important! Note that because this is essentially a canvas, 0x0 is the left hand corner regardless of where I render it later.
              printAt( 0, 0, "Meh" )
            return void
            
            waldron 1 Reply Last reply Reply Quote 3
            • waldron
              waldron F @pobtastic last edited by

              @pobtastic thank you that's pobtastic :)

              1 Reply Last reply Reply Quote 2
              • pobtastic
                pobtastic F last edited by

                No problem at all, we're all in this together!

                waldron 1 Reply Last reply Reply Quote 3
                • waldron
                  waldron F @pobtastic last edited by

                  @pobtastic iv put in the code it just makes my sprite disappear when i press the button???

                  1 Reply Last reply Reply Quote 0
                  • pobtastic
                    pobtastic F last edited by

                    Don't forget to make sure you're using the default framebuffer again, maybe you're clearing the display? Else ... maybe your image is too big, are you scaling it?

                    waldron 1 Reply Last reply Reply Quote 0
                    • waldron
                      waldron F @pobtastic last edited by

                      @pobtastic lost mate i put in the code which i understand some of it (create a colored box with specified text "meh")
                      and i made sure i drawimage after my sprites and map layers but i press the button my character gos invisible...
                      its cool but not what im after lol

                      1 Reply Last reply Reply Quote 0
                      • pobtastic
                        pobtastic F last edited by

                        Oh so wait ... it works then, it's just that your character sprite goes invisible?

                        1 Reply Last reply Reply Quote 0
                        • waldron
                          waldron F last edited by

                          no, il try and reread the code you posted i may of put something in the wrong place. just to clarify
                          this is to print a message on the screen when my character presses a button within the game at certain locations

                          1 Reply Last reply Reply Quote 0
                          • pobtastic
                            pobtastic F last edited by pobtastic

                            Yup, try out the code I posted ~ it actually works better than I thought it might ;) The screen is a constantly changing mess of different coloured blocks, and when you press "x" you get a small dialogue box appear until you release it again (on top of the same screen).

                            It's maybe not the most useful of demos, feel free to make any suggestions that style it more to how you're using fuze and I'll update it.

                            waldron 1 Reply Last reply Reply Quote 0
                            • waldron
                              waldron F @pobtastic last edited by waldron

                              @pobtastic I don't know if it's a different style of code your using that's not compatible with my set up il take another look maybe just put something in the wrong place knowing me

                              Maybe a way of incorporating the new flags in maps or named boxes would be a preferred way

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post