coatesjetset's Recent Forum Activity

  • And I found another bug already, though it's just cosmetic. If you start a click on the button, then (while still holding down the button or touching the screen) drag off the button, then back onto the button, the last action doesn't put the button visually back in the "clicked" image. The OnClicked action fires correctly, it's just the image. WOrking on it now.

  • anata: did you install the .c2addon first? It also looks like you may have another addon conflicting with mine, which is just named "SpriteButton" -- I can certainly rename mine if that's the problem.

    Also, I have updated both the .c2addon and the .capx example. I think I've squashed the bugs for now.

  • and I've found the culprit code and am fixing the bug. New version incoming soon.

  • I've found a bug already. I'm not getting my inputUp events being triggered when on a touch display (it works fine with a mouse)

    dropbox.com/s/c8coqjrda2b784w/SpriteButtonTest.capx

    This is a simple project with a single sprite with my SpriteButton behavior attached (which you will need to get from the above link) -- it should change to the hover/click image as expected and play a sound when clicked. On a normal desktop browser, it works fine. On the iPad, it's like I get no event when a touch ends, as the button stays in whatever visual state it was before the touch ended, and the sound never plays.

    Any clues would be appreciated. Note that this is a bug in the javascript for my behavior, not in the project itself. :)

  • I have my current version at dropbox.com/s/x46uie9isi0cvn3/SpriteButton.c2addon

    and a topic over in the "share your plugins" section, so this topic is closed.

  • behavior plugin at:

    dropbox.com/s/x46uie9isi0cvn3/SpriteButton.c2addon

    sample at:

    dropbox.com/s/c8coqjrda2b784w/SpriteButtonTest.capx

    Latest version: 1.3

    To install, just drag the .c2addon into your construct2 window, then restart Construct2.

    (I don't have the rep yet to post a direct link, sorry! Will fix when I am able.)

    This is my attempt at a SpriteButton behavior plugin. Just add it to a Sprite and set up which animation frames you would like to use for its normal, hover and click images. Don't forget to set the animation speed to 0 or the animation will play when the layout is first loaded.

    There is an OnClick event that is fired when the user releases a touch/mouse click on the button. There will eventually be more events added for when the mouse/touch first hits a button, when hovering, etc, but the event on touch/click release is the most important, so I did that one first.

    There is also a "Status" expression that is used for debugging purposes. Don't rely on any information from this, as it will definitely change depending on my needs at the moment. :)

    While I am a professional C#/C++ programmer, I'm relatively new to JavaScript and have only been using Construct2 for a little while, so I'm sure there are plenty of bugs and improvements to be made. A lot of the code was copied wholesale from the DragNDrop behavior, so there may be unintended side effects of that, though I think I have a reasonable grasp of what's going on. I welcome all feedback.

  • Okay, I've gotten most of the things figured out and don't need any immediate help. Forum posts and looking at the dragndrop behavior seemed to have most of the answers I need.

  • I'm making some progress on this, and I've hit a problem. I figure I'd toss it out here in case someone knows the answer before I stumble upon it. I notice that the button plugin has code to register an onClick handler for the html button and hook into that to fire the OnClicked condition. Can I do this if my SpriteButton is a behavior attached to a Sprite object? I'm not seeing an obvious way to do it.

    I will continue to search through the forums and docs, but in case it's an easy answer that I'm just missing, thought I'd toss it out here.

  • If we end up using Constuct2 for this project, it will be a team of artists (non-programmers) and programmers (like me) -- so, my main job will most likely be to make plugins like this so that the artists don't have to do any scripting. The quicker I can get up to speed, the better.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So far I am very impressed with Construct2. I would like to make a "SpriteButton" plugin (I know some are available, but this is for learning how to make plugins)

    I currently have a project that does what I want, I'm just not sure about the best way to make it a reusable component.

    My "manual method"

    Create a Sprite, set up image to have 3 frames (normal, hover, pressed) and define those frames in the sprite animation window.

    defined the following events:

    mouse: Cursor is over (sprite) --> (sprite) set animation frame to 1

    mouse: Cursor is not over (sprite) --> (sprite) set animation frame to 0

    touch: isTouching (sprite) --> set animation frame to 2 (& my game-specific actions)

    with touch enabling mouse input, this works for what I want. So, on to the detailed questions:

    If I want to make this a reusable component, would it be better to make it a behavior that is attached to a sprite, or a new object type?

    With the expectation that every "SpriteButton" would have the same frames defined in the same order in the source image, the goal is to have the plugin automatically set the right frame without any further action from the user other than selecting the source image. Then, it would define its own event(s), such as SpriteButton:IsPressed to do the game logic. Is this the right way to design this? I am happy to look at the existing behaviors/plugins to do the low-level coding (I am reasonably adept at JS) but would like to ensure that I'm starting out on the right foot.

coatesjetset's avatar

coatesjetset

Member since 30 Aug, 2013

None one is following coatesjetset yet!

Trophy Case

  • 11-Year Club
  • Email Verified

Progress

12/44
How to earn trophies