SpriteButton

Post your completed addons to share with the community

Post » Fri Sep 06, 2013 9:17 pm

behavior plugin at:

https://www.dropbox.com/s/x46uie9isi0cvn3/SpriteButton.c2addon

sample at:
https://www.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.

coatesjetset2013-09-12 18:55:05
B
6
S
1
Posts: 22
Reputation: 446

Post » Sat Sep 07, 2013 12:12 am

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)

https://www.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. :)
B
6
S
1
Posts: 22
Reputation: 446

Post » Sat Sep 07, 2013 12:25 am

and I've found the culprit code and am fixing the bug. New version incoming soon.
B
6
S
1
Posts: 22
Reputation: 446

Post » Sat Sep 07, 2013 12:37 am

i have this error when i try your capx



and



Why ? :D
B
38
S
13
G
4
Posts: 152
Reputation: 5,147

Post » Sat Sep 07, 2013 12:43 am

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.
B
6
S
1
Posts: 22
Reputation: 446

Post » Sat Sep 07, 2013 12:47 am

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.
B
6
S
1
Posts: 22
Reputation: 446

Post » Sat Sep 07, 2013 1:24 am

anata: I found your bug as well. Not sure why I'm not getting that error here when I load the plugin. Anyway it will be fixed soon.
B
6
S
1
Posts: 22
Reputation: 446

Post » Sat Sep 07, 2013 2:06 am

Version 1.2 uploaded with working sample. Will change top message.
B
6
S
1
Posts: 22
Reputation: 446

Post » Tue Sep 10, 2013 1:57 am

The most recent version does not exhibit intended behavior on IE10 (I don't think IE is doing anything wrong, it's just that I was assuming that a mouse move event would have correct data in the "info.which" field, which is not true, and IE behaves differently with what garbage data is in the field versus Chrome)

So, doing a partial rewrite now that I grok what's going on more.
B
6
S
1
Posts: 22
Reputation: 446

Post » Thu Sep 12, 2013 3:29 pm

@coatesjetset very nice work, such kind of plugin will help a lots of people like me. Keep up the good work and make the plugin more nice and good. Thanks for the share.

One more thing , I am confused about how to install this. Can you please let me know through PM or just write a method in your first post.thehorseman0072013-09-12 15:33:32
B
97
S
20
G
15
Posts: 198
Reputation: 14,596

Next

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 0 guests