Jump to content


  • Content Count

  • Joined

  • Last visited

  1. Okay, sorry - I was looking at the easing section. Thanks.
  2. Is the repeat function documented somewhere? I ask because I would like to understand the available parameters. Same for start() which I assume has a stop() - which would be valuable to me.
  3. Thanks for the responses. Quick question - are tweens the best way to accomplish this? Ideally I would like to adjust the position of the sprite with x,y but once then I need some sort of conditional logic with a timer to make sure it does not get called every second in the loop. Tweens seem to have the advantage of moving to a targeted spot and then stopping. What is best practice? Also, @lewster32 - great function - thank you very much for demonstrating it. Is the last part also somewhat undocumented? I briefly looked at tweens and did not see it: tween.repeat(Infinity); tween.start(
  4. Super newb here again with a pretty basic question. i managed to spawn a group and thanks to a mod post I figured out that easing does not play well with physics so I set the body.move to false and case ease from one spot to another. I then tried to create a zig-zag pattern with easing in chunks: tween = game.add.tween(enemies.getAt(1)).to( { x:enemies.getAt(1).x-20, y:enemies.getAt(1).y+20}, 2400, Phaser.Easing.Circular.In, true);tween = game.add.tween(enemies.getAt(1)).to( { x:enemies.getAt(1).x-20, y:enemies.getAt(1).y-20}, 2400, Phaser.Easing.Circular.In, true);tween = game.add.tween(ene
  5. @lewster32 thank you for the tween guidance. I set body.moves to false and sure enough the tweens work and collisions still work.
  6. This thread might answer a question for me as well. I am working on a space shooter that starts with a group of enemies. I want them to individually break off from a formation and attack (i.e. like classic Galaga game). I can identify them with getAt(index) but I have been struggling to figure out to make them move in a specific pattern that uses precise coordinates. The movements with a tween are very choppy / jerky. Are you saying that the physics engine prevents this (which would explain why my tweens look terrible)? If so, can I detect collisions without the physics engine?
  7. @JUL ... I am not doing anything yet except for creating everything. Maybe my syntax is wrong? enemies.getAt(1).body.velocity.x-=1; // worksenemies.getFirstAlive().body.velocity.x-=1; // does nothing
  8. @Heppell08 - if I understand your post correctly that would be fine for iterating every member of the group to a common action (setAll might work too). However, I just want to work with individual members of the group without regard to disturbing t he rest of the group. That is why enemies.getAt(1).body.velocity.x-=1; works to a degree by allowing me to select any one member of the group to move. That was the thrust of the original post. However, I still don't understand why group.getFirstAlive().body.velocity.x-=1; does not do the same thing ...
  9. horizGravity currently = 0 so that would not do anything ... it is the same as * -1. I shut off the gravity in favor of trying to move members of the group. I know that on creation I could do something like this: body.velocity.x = game.rnd.integerInRange(-200, 200);to set the individual members in motion. Now I am trying to call them individually after the creation to move them. I wanted to start with firstAlive ... but I don't know why it does not work. EDIT: I am trying to do this in the update loop by calling the function function leaderAttack(){var leader=enemies.getFirstAlive();lead
  10. Okay, now it says "[object Object]" in the alert. This is how I create the members of the group: //enemies enemies=game.add.group(); enemies.enableBody = true; enemies.physicsBodyType = Phaser.Physics.ARCADE; // enemies.createMultiple(30, 'galaga'); for (var i = 0; i < 7; i++) { yellowJacket = enemies.create(game.world.width-40, 75 * i, 'galaga', 'yellowJacket'); yellowJacket.body.gravity.x = horizGravity*-1; } for (var i = 0; i < 6; i++) { yellowJacket = enemies.create(game.world.width-90, (75 * i)+100, 'galaga', 'yellowJacket'); yellowJacket.body
  11. The alert(console.log(leader)); shows "undefined" The code for the invaders has the whole group moving - which I can do. This is what the aliesn do - which I believe impacts the entire group. function descend() { aliens.y += 10;}I am wondering how to get the first alien to move some way without moving the others in the group.
  12. @j0hnkot I apolgize for this question (I admit to beeing a noob) ... but I added the console.log(leader) code. Where am I supposed to see the output? In the browser? If so, I see nothing.
  13. Thanks @j0hnkot and @Jul @j0hnkot Group.getRandom() does indeed look useful, thanks. @Jul: I tried this function called from the update state but nothing happens - no error and no movement. function leaderAttack(){var leader=enemies.getFirstAlive();leader.body.velocity.x-=10;}Any thoughts?
  14. Hello all. I just discovered Phaser.io and think it is great. I am a bit stuck, however, on how to manipulate members of a group. I have a space shooter where I spun up about a dozen enemies within a group. Now I want to select individual members of the groups to move toward the player in some pattern. I can't figure out how to get just one member of the group. I tried something like: var leader=enemies.getFirstAlive();leader.x-=1; but it did not work. Also, what if I wanted it to be a random enemy that was alive? Any guidance would be most appreciated.
  • Create New...