• Content Count

  • Joined

  • Last visited

  1. If that were true then I dont understand how the position part works well whereas only scale doesnt
  2. Hey guys.I wanted to make a fuctionality through which If i select a sprite its gets replaced by a highlighted version of that sprite(the ones with selected in their name) and the other objects become rplaced by their unhighlighted version however with the current code whats happening is when testing the program it seems to be making an stran instance of the unhighlighted versions. function create () { mothership = game.add.sprite(90,100,"mothership"); mothership.inputEnabled=true; mothership.events.onInputDown.add(listener,this); bots=game.add.group();//the bots group bot1=bots.create(400,100,'bot1'); bot1.inputEnabled=true; bot1.events.onInputDown.add(listener,this); bot2=bots.create(700,100,'bot2'); bot2.inputEnabled=true; bot2.events.onInputDown.add(listener,this); } function listener(sprite, pointer) { if(sprite==mothership) { sprite.kill(); MothershipSelect(); Bot1(); Bot2(); } if(sprite==mothershipSelected) { sprite.kill(); Mothership(); } if(sprite==bot1) { sprite.kill(); Bot1Select(); Mothership(); Bot2(); } if(sprite==bot1Selected) { sprite.kill(); Bot1(); } if(sprite==bot2) { sprite.kill(); Bot2Select(); Mothership(); Bot1(); } if(sprite==bot2Selected) { sprite.kill(); Bot2(); } } function MothershipSelect() { mothership.kill(); mothershipSelected = game.add.sprite(80,100,"mothershipSelected"); mothershipSelected.inputEnabled=true; mothershipSelected.events.onInputDown.add(listener,this); } function Mothership() { mothershipSelected.kill(); mothership = game.add.sprite(90,100,"mothership"); mothership.inputEnabled=true; mothership.events.onInputDown.add(listener,this) } function Bot1() { bot1Selected.kill() bot1=bots.create(400,100,'bot1'); bot1.inputEnabled=true; bot1.events.onInputDown.add(listener,this); } function Bot1Select() { bot1.kill(); bot1Selected=bots.create(400,100,'bot1Selected'); bot1Selected.inputEnabled=true; bot1Selected.events.onInputDown.add(listener,this); } function Bot2() { bot2Selected.kill(); bot2=bots.create(700,100,'bot2'); bot2.inputEnabled=true; bot2.events.onInputDown.add(listener,this); } function Bot2Select() { bot2.kill(); bot2Selected=bots.create(700,100,'bot2Selected'); bot2Selected.inputEnabled=true; bot2Selected.events.onInputDown.add(listener,this); }
  3. Thanks a lot guys .both of you.you have to cycle through each bot to verify like moe91 said and XekeDeath you were right too thebots.alpha doesnt work.bots.setAll('alpha',1) works fine.just one question tho if i wanted to set only a few specific bots to alpha what would I do?
  4. Guys I have the following code to make a star sprite and 2 firstaidbox(added through group) sprites.what i want is that when i click the star the firstaid boxes should dim(alpha=0.5) and vice versa.however the mouse event doesnt seem to work when I click the firstaid boxes. function create () { starimage = game.add.sprite(100,100,"star"); starimage.inputEnabled=true; starimage.events.onInputDown.add(listener,this) bots=game.add.group();//the firstaid boxes for(var i=2;i<4;i++) { var myvar=bots.create(i*100,100,'firstaid'); myvar.inputEnabled=true; myvar.events.onInputDown.add(listener,this); } } function listener(sprite, pointer) { if(sprite==starimage) { sprite.alpha = 0.5; bots.alpha=1; } if(sprite==bots) { alert("clicked"); sprite.alpha = 0.5; starimage.alpha=1; } }
  5. unity code double turret_scale_x=(turret_reference[index].transform.localScale.x-standardscale)/2; double turret_scale_y=(turret_reference[index].transform.localScale.y-standardscale)/2; if(turret_scale_x<=1) turret_scale_x=1; if(turret_scale_y<=1) turret_scale_y=1; m.AddField("scalex",(float)turret_scale_x); m.AddField("scaley",(float)turret_scale_y); original scale value=6.5 changed to:18.65 but wen i use thes same stats in phaser using the scaleto(12,12,'turret'); it makes the thing HUGE,far bigger than the unity output
  6. Hey guys,Ive been working on making a level editor in unity and then storing the resultant transform information like scale,position and rotation in a.json file to be read by phaser.while the position and rotation work perfectly well by changing the pivot of the sprites in unity.the scale doesnt seem to work ie the scaling in unity doesnt show the same result in phaser.if anyone has suggestion on how to calibrate it please let me know.
  7. rahulng

    Phaser Json Read

    Thx guys.I got my solution by using a jquery function to read the json file using an ajax command
  8. After doing these 3 steps game.load.text('someData', '/my/file.json'); var jsonData = JSON.parse(game.cache.getText('someData')); game.cache._text['someData'] = JSON.parse(game.cache.getText('someData')); how do I display the the Json p[roperties as text on the page?
  9. rahulng

    Phaser Json Read

    Ive tried that here let me sho you the code game.load.atlasJSONHash('myJsonobj','bird.png','TestFile.json');//reading the JSOn file text=frames.bird.frame.x; but this doesnt seem to work
  10. HI, Im a newbie to Phaser and I have a project goin on in which i simply want to read the contents(properties) of a Json file and display them.but I seem to have hit a road block heres the JSON file { "frames": { "bird":{ "frame": { "x": 0, "y": 0, "w": 98, "h": 106 }, "sourceSize": { "w": "1024", "h": "768" } } }, "meta": { } } I want to access and display the the x: and y: values in the frame property.any help would be realy appreciated