aaron.g...@gmail.com
unread,Aug 23, 2016, 10:47:30 AM8/23/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message as abuse
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to melonJS - A lightweight HTML5 game engine
Looking at the pointer event code inside the engine, try returning true instead of false. Similar to our collision system, it means you're confirming that something happened with this event. Returning false is handy if you want the click event to register against multiple objects.
I realize it's a bit reverse from typical browser patterns, but it also matches how one uses callbacks in game systems typically. I don't recall when this was added if there was another reason for that choice.
On Tuesday, August 23, 2016 at 6:54:11 AM UTC-4, Danny Z wrote:
> Hello,
>
>
> I apologize for the question, I'm sure it was already answered, but all similar issues are years old and links are dead, so thought I'd ask here.
>
>
>
>
> So, I've just started learning Melon a bit and I ran into an issue I can't resolve.
> Namely, if I place a layer (Sprite) over the screen, if I click on a place that has something behind it, that event is triggered.
>
>
> Now, the problem might be that I'm using the buttons wrong, but there just could be a way to prevent this from happening. Apparenty adding false
>
>
>
>
>
>
>
>
> Here is what I have:
>
>
>
>
>
>
> start_game = me.GUI_Object.extend({
> init : function (a, b) {
>
>
>
> var c = {};
>
>
> c.image = "button",
>
>
> c.framewidth = 152,
>
>
> c.frameheight = 75,
>
>
> this._super(me.GUI_Object, "init", [a, b, c])
>
>
> },
> onClick : function (a) {
>
>
>
> return me.state.change(me.state.PLAY), false
>
>
> }
> })
>
>
>
>
>
>
>
>
> call_menu = me.GUI_Object.extend({
> init : function (a, b) {
>
>
>
> var c = {};
>
>
> c.image = "button",
>
>
> c.framewidth = 152,
>
>
> c.frameheight = 75,
>
>
> this._super(me.GUI_Object, "init", [a, b, c])
>
>
> },
> onClick : function (a) {
>
>
>
> var b = me.loader.getImage("layer_bg");
>
>
> me.game.world.addChild(new me.Sprite(me.video.renderer.getWidth() / 2 - b.width / 2, me.video.renderer.getHeight() / 2 - b.height / 2, {
>
>
> image : b
>
>
>
> }), 12);
>
>
> return false
>
>
> }
> })
>
>
>
>
>
>
>
>
>
>
>
>
> If I click on the area where "start:game" is (behind the sprite), it counts as being clicked on. Any way to prevent this?