Coast2Coast Posted March 16, 2016 Share Posted March 16, 2016 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 Link to comment Share on other sites More sharing options...
Coast2Coast Posted March 16, 2016 Author Share Posted March 16, 2016 Wow! I'm seeing there's no possible to draw a group as it. Maybe dragging a sprite or something and use de update to move others Here are a challenge! I think my huge doubt is how to drag a group? Link to comment Share on other sites More sharing options...
Recommended Posts