• Content Count

  • Joined

  • Last visited

About asalinasci

  • Rank

Contact Methods

  • Twitter

Recent Profile Visitors

723 profile views
  1. I run and I have made all the educational games there. If you want to collaborate send me a message to
  2. I know that it is not a good idea to rotate sprite using arcade physics (AABB), but if my sprites are rectangles and I want to rotate 90 degrees....Does this work? I try changing body size (Height - Width) but it doesn't work. (Sorry for my English)
  3. Thanks @Batzi for your answers, I have learned a lot with your suggestions. And I remove some code from update functions. But @drhayes has put me on the road to the solution. I use the "puntoDentro" function to know if the sprite has arrived to the random target. I use getBounds to make a rectangle with the bounds and test if the target point is inside it. And the problem is that getBounds give the coordinates in the "screen" not in the "world". I added the camera coordinates to the rectangle coordinates and now works fine. Old bad version: Juego.puntoDentro=function(punto, sprite){ var a=new Phaser.Rectangle(punto.x, punto.y, 1, 1); var b = sprite.getBounds(); return Phaser.Rectangle.intersects(a, b); }; New good version: var a=new Phaser.Rectangle(this.objetivo.x, this.objetivo.y, 1, 1); var b = this.getBounds(); b.x +=; b.y +=; if(Phaser.Rectangle.intersects(a, b)){ //when arrives to the target, random generate a new targete this.nuevoObjetivo(); } Thanks a lot.
  4. Thanks. I will try another way to do the same.
  5. I have put a console.log inside the "if" and before "this.nuevoObjetivo". When starts the "problem", never execute the console.log. It is like when this happen, the x properties of the objects increment/decrement constantly. I put "" without condition, always execute. I'm going to make my own "moveToXY" and give it a try.
  6. If I remove ... camera.follow() and in the update function I put ...; I have the same problem.
  7. If I remove camera.follow(), the other sprites are moving perfect in any directions.
  8. (Sorry for don't use the code tag, it's my first time in the forum)*.5, Juego._HEIGHT, gr.generateTexture());;, Phaser.Physics.ARCADE); this.jugador.enableBody = true; this.jugador.physicsBodyType = Phaser.Physics.ARCADE; this.jugador.body.collideWorldBounds=true; this.jugador.anchor.setTo(0.5, 0.5); gr.destroy();, 960);; And the update function: update: function(){ var distance =, this.jugador.body.y, +, +; // If the distance > MIN_DISTANCE then move if (distance > this.MIN_DISTANCE) { // Calculate the angle to the target var rotation =, this.jugador.body.y, +, +; // Calculate velocity vector based on rotation and this.MAX_SPEED this.jugador.body.velocity.x = Math.cos(rotation) * this.MAX_SPEED; this.jugador.body.velocity.y = Math.sin(rotation) * this.MAX_SPEED; } else { this.jugador.body.velocity.setTo(0, 0); } },
  9. I don't apply camera.follow() to the other objects. This is the code for the objects randomly moving: var Burbuja=function(radio, color, auxGame){||50; this.color=color||0x00ff00; var; gr.beginFill(this.color); gr.drawRect(0, 0,,;, auxGame, Math.random()*750, 630 + Math.random()*250, gr.generateTexture()); this.anchor.setTo(0.5, 0.5); gr.destroy(); auxGame.physics.enable(this, Phaser.Physics.ARCADE); auxGame.add.existing(this); this.auxGame=auxGame; this.TURN_RATE = 2; this.velocidad=150; this.enableBody = true; this.physicsBodyType = Phaser.Physics.ARCADE; //this.body.collideWorldBounds=true; this.objetivo=new Phaser.Point(); this.body.y=600+Math.random()*260; this.body.x=50+(Math.random()*; this.nuevoObjetivo(); this.volando=true; } Burbuja.prototype=Object.create(Phaser.Sprite.prototype); Burbuja.prototype.constructor=Burbuja; Burbuja.prototype.nuevoObjetivo=function(){ //random change fly direction var signo=this.auxGame.rnd.integerInRange(0, 1)?-1:1; var inc= signo*this.auxGame.rnd.integerInRange(75, 250); this.objetivo.x=((this.body.x + inc)< && (this.body.x + inc)>0)?this.body.x+inc:this.body.x-inc; signo=this.auxGame.rnd.integerInRange(0, 1)?-1:1; inc= signo*this.auxGame.rnd.integerInRange(75, 250); this.objetivo.y=((this.body.y + inc)< && (this.body.y + inc)>0)?this.body.y+inc:this.body.y-inc; }; Burbuja.prototype.update=function(){ if(this.volando){ this.auxGame.physics.arcade.moveToXY(this, this.objetivo.x, this.objetivo.y, this.velocidad); var targetAngle = this.auxGame.math.angleBetween(this.body.x, this.body.y, this.objetivo.x, this.objetivo.y)+Math.PI/2; if (this.rotation !== targetAngle) { var delta = targetAngle - this.rotation; if (delta > Math.PI) delta -= Math.PI * 2; if (delta < -Math.PI) delta += Math.PI * 2; if (delta > 0) { this.angle += this.TURN_RATE ; } else { this.angle -= this.TURN_RATE ; } if (Math.abs(delta) < { this.rotation = targetAngle; } } if(Juego.puntoDentro(this.objetivo,this)){ //when arrives to the target, random generate a new targete this.nuevoObjetivo(); } } }
  10. (Sorry for my English) In a Phaser game, I have some sprites moving automaticly and randomly in a world bigger than the game size using moveToXY. And they work fine. I add an sprite "player" controlled with the mouse and the camera follows it. When this "player" moves the camera, the other sprites start to "trembling" without moving. If the "player" return to the initial screen, every sprites start to moving fine. It looks like the camera moving affect to moveToXY. Is this possible? Is there a way to avoid this behaviour?