Search the Community
Showing results for tags 'gui_object'.
-
Hi guys. I'm trying to do a "zoom in" effect on a GUI_Object. But when scaling the image leaves the original collision field. How to keep the image centered with the collision field of the button? Before click: After click: Code: game.UI.ButtonInit = me.GUI_Object.extend({ init: function (x, y, image) { this._super(me.GUI_Object, "init", [x, y, { image: image, }]); this.anchorPoint.set(0, 0); this.floating = false; }, onClick: function () { this._super(me.Sprite, "scale", [.8, .8]); }, update: function () { return true; }, draw: function (renderer) { this._super(me.GUI_Object, "draw", [renderer]); } });
- 7 replies
-
- gui_object
- scale
-
(and 1 more)
Tagged with:
-
currently im using method setRegion to change frame on GUI_Object, but i want change it like Entity using setCurrentAnimation. this.renderable = game.texture.createAnimationFromName(imgNames); this.renderable.addAnimation ("on", [0]); this.renderable.addAnimation ("off", [1]); this.renderable.setCurrentAnimation("on"); When i run this code on GUI_Object i got an error. So how to achieve this on GUI_Object ?? thanks
- 2 replies
-
- melonjs
- gui_object
-
(and 1 more)
Tagged with:
-
Sorry if this has been covered already, but I wasn't able to find anything via searches. I have a game I started with the boilerplate. In the TitleScreen, I've added a "Play" button that appears in the lower center of the canvas. The button is displaying fine, but the clickable area appears to be a box roughly the size of the button, but starting at the center of the button. So the button actually appears centered on the position I placed it, but the clickable area is if the top left was at that position. I was going to dig into the melonjs code and determine what's happening, but I wanted to see if this is because of something I'm doing incorrectly. melonJS Game Engine v4.1.0 var PlayButton = me.GUI_Object.extend({ init: function(x, y) { var settings = {}; settings.image = "btnplay"; settings.framewidth = 250; settings.frameheight = 100; // super constructor this._super(me.GUI_Object, "init", [x, y, settings]); // define the object z order this.pos.z = 4; }, onClick: function () { // Change to the PLAY state when the button is clicked me.state.change(me.state.PLAY); return true; } }); game.TitleScreen = me.ScreenObject.extend({ /** * action to perform on state change */ onResetEvent: function() { // Load background image me.game.world.addChild( new me.ImageLayer(0, 0, { image : "launch", z: 0 // z-index } )); me.game.world.addChild( new PlayButton(480, 480), 10 // z-index ); }, /** * action to perform when leaving this screen (state change) */ onDestroyEvent: function() { // TODO } }); Also, I have the z-index at 10 because 1 wasn't working for some reason.