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.
    • 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