Make a "SpriteButton" plugin

0 favourites
  • 6 posts
From the Asset Store
I18N - Translation plugin
$7.20 USD
10% off
The I18N (Translation) is a Construct plugin created to translate text in game.
  • 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.

  • The events are fairly easy to set up, but on the other hand you get the experience.

    For that alone I'd say go for it.

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

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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)