Search the Community
Showing results for tags 'enabledrag'.
-
how do i use the input.enableDrag(false) feature with tilemaps? it does not seem to work. It just says "Cannot read property 'enableDrag' of undefined(…)". I know the tilemap works because I am already using it somewhere else but not in the same file. Any help would be amazing!
-
Hi, How is the correct form to enable a graphic draw? Here is my code: // create fn : this.game.physics.startSystem(Phaser.Physics.ARCADE); // posicion del grupo en el escenario: var _y = 0; var _G = this.game.add.group(); for(var i=0;i<20;i++){ var p = this.doSome(i); // trying to create graphics inside a group or sprite ??? if(i>0){ p.x = (50*(i%5)); p.y = _y; } if(i%5==4){ _y = _y+50; } // p.enableBody = true; // p.inputEnabled = true; // p.input.enableDrag(false, true); _G.add(p); // console.log(p); } _G.setAll('inputEnabled',true); _G.callAll('input.enableDrag','input'); // ,parameter _G.x = (this.game.world.width*0.5) - (_G.width*0.75); _G.y = (this.game.world.height*0.5) - (_G.height*0.75); // window.graphics = rect; }, // end create doSome: function(num){ var rect = this.game.add.graphics(100,100); rect.beginFill(0xFF3300); rect.lineStyle(3,0xFFCC33,1); rect.drawRect(-25,-25,50,50); rect.endFill(); var txt = this.game.add.text(0,0,null,{align:'center'}); txt.anchor.setTo(0.5,0.5); txt.x = rect.x; txt.y = rect.y; txt.text = num+1; var gp_ = this.game.add.group(); gp_.add(rect); gp_.add(txt); gp_.name = 'gpo'+num; // gp_.inputEnabled = true; // gp_.mousedown(this.clickable,this); // gp_.inputEnabled = true; // gp_.input.enableDrag(false, true); // console.log(gp_.name,num); return gp_; }, Console sends and error when I am using inputEnabled, and it says p.input is undefined Need some help I'm very beginner with phaser, and don't know clearly how do nested objects work This is what I want to do: - Create a group and move all together - Inside it create two elements: graphic.drawRect, and over it create a text, - I want to drag both elements at same time, so I put them into another group!, or how is it? Well, If somebody have an idea I would be glad! thanks
-
Hi All, I am trying develop a game that contains a color band of 5 different colored rectangles. So I created a group and added those rectangles to it(I have uploaded the image of the output). Now I am trying to write the code in such a way that the entire group will be moving horizontally once I drag it. But from what I found we can make the individual element in the group draggable but not the entire group. Anyways, I did write the code this way but I think its wrong as its not working. Here it is. var leftRectGroup = game.add.group(); var colorarray = ["0x607D8B", "0xFF5722", "0xFFEB3B", "0x9E9E9E", "0x795548"]; for(var i = 0; i < 5; i++){ var rectanglegraphics = game.add.graphics(0,0); rectanglegraphics.beginFill(colorarray, 1); rectanglegraphics.drawRect(0, i*256, 100, 256); leftRectGroup.add(rectanglegraphics); rectanglegraphics.endFill(); } leftRectGroup.inputEnabled = true; leftRectGroup.input.enableDrag(); leftRectGroup.input.allowHorizontalDrag = false; Can anyone please provide me the right snippet to make the entire group draggable at once. Thanks in Advance.