coatesjetset's Forum Posts

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

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