jilonor

Members
  • Content Count

    12
  • Joined

  • Last visited

  1. Thanks for the answer Also, when I inspect the sprite properties, there is the previousPosition one which seems to contain the correct coordinates but appears to be updated asynchroniously or something... not sure. well to be accurate, I made this function in the end : function GetRotated(cx, cy, x, y, angle) { var radians = (Math.PI/180) * angle; var translatedX = (x - cx) * Math.cos(radians) - (y - cy) * Math.sin(radians) + cx; var translatedY = (x - cx) * Math.sin(radians) - (y - cy) * Math.cos(radians) + cy; return {x: parseInt(translatedX), y: parseInt(translatedY)}; }
  2. Hi, I have been generating planet systems. All planets are set to pivot around the same point. There is no physics involved, just static display. this.planetSprite = game.add.sprite(x, y, skin); this.planetSprite.scale.setTo(size); this.planetSprite.anchor.setTo(0.5); this.planetSprite.pivot.x = orbite/size; this.planetSprite.rotation = getRandomInt(0,360); The rotation and display is working fine but the coordinates are not updated after rotation. Is there a specific property to call to get new coordinates or should I manually calculate it? thanks
  3. bullet.body.fixedRotation=true; did the trick
  4. So im trying to do a space shooter based on p2 physics thrust exemple. in the create method : game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.defaultRestitution = 0.5; this.bullets = game.add.group(); this.bullets.enableBody = true; //this.bullets.physicsBodyType = Phaser.Physics.P2JS; this.bullets.createMultiple(8, 'laser'); this.bullets.setAll('anchor.x', 0.5); this.bullets.setAll('anchor.y', 0.5); Then in the update method i call this function fire: function () { if (this.time.now > this.bulletTime) { var bullet = this.bullets.getFirstExists(false); var p1 = new Phaser.Point(this.ship.x, this.ship.y); var p2 = new Phaser.Point(this.ship.x, this.ship.y - 80); p2.rotate(p1.x, p1.y, this.ship.rotation, false); if (bullet) { bullet.reset(p2.x, p2.y); bullet.lifespan = this.bulletLifespan; bullet.rotation = this.ship.rotation; this.bulletTime = this.time.now + 250; } } } As you noticed I commented the line about settings groups physics to P2JS. The rotation of the laser sprite and its relative positioning to the ship is perfect but right after I uncomment the line; the laser sprite no longer rotate. Its positionning is still relative to the ship rotation but the laser sprite stays straight (point to the top of the screen as the inital image is). Is it suggested to choose ARCADE physics for games using rotations? Also, which property of bullet should i call to make it move on the current angle and direction? Thx
  5. Hi, I am creating a game which is using a dynamic map generation including several separated areas. Each area will have its own specific logic and events. So i was planning to deal with that using states but i am not sure how to structure it since there will be like 30 area type. Any suggestions? thx in advance
  6. have you tried switching the initialization to Phaser.CANVAS? I also added game.camera.roundPx = false;
  7. thanks a lot for the answer. So this fixes the initialization but i would also want to reset all previous selection when entering the callback. And I can't manage to access the group (this.selectorGroup). Doesnt seems to be initialized in this context.
  8. jilonor

    Dynamic tiles

    Hi, I have been using the tilemap editor TILED http://www.mapeditor.org/ I noticed there is a way to preset animations with tiles. basically, make 2 tiles switch periodically. Is there a way to compute these animations when loading the tilemap? thanks
  9. Hello, i was trying to attach eventListeners to sprites. I did that in the create function : this.selectorGroup = game.add.group();height = 200;// looping through json for(var key in res){ var selector = game.add.sprite(625, height - 10, "resourceSelector"); selector.inputEnabled = true; // adding some custom property selector.data = key; // attaching eventListener selector.events.onInputUp.add(this.triggerSearch); // adding the sprite to a group this.selectorGroup.add(selector); height = height+40;}// setting all elems of the group to alpha 0this.selectorGroup.alpha = 0;then in the callback function : triggerSearch = function (item, pointer) { // this is working console.log("looking for ", item.data); // hide previous selections this.selectorGroup.alpha = 0; // this isnt working item.alpha = 1;};also, i cant access the selectorGroup to apply alpha 0 to all children in order to reset previous selections. though, if i dont set alpha to 0 to sprites in create function and i put item.alpha = 0 in the callback, i can remove opacity from the sprites... Am i missing something?