QuentinIcky

Members
  • Content Count

    17
  • Joined

  • Last visited

About QuentinIcky

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Yes you're right. I finally succeed to do it by making another spritesheet thanks !
  2. Hi all ! As the title said, I have a sprite sheet who has a strange behaviour. It's difficult to explain so you can see the uploaded file to see. I add my sprite sheet like this inside the preload() : level2.load.spritesheet('hil', 'dest/img/sprite-Level2.png', 373, 265, 8); In the create() : player = level2.add.sprite(380, level2.height - 430, 'hil', 1); player.frame = 0; player.enableBody = true; player.scale.setTo(0.5); player.animations.add('left', [0,1,2,3,4,5,6,7,8], 5, true); And in the update() : if (cursors.left.isDown) { player.body.velocity.x = -800; player.animations.play('left'); } I searched a lot but I didn't find anything to help me. I can't understand why it doesn't work. If somebody knowes, it could be very helpfull. Thanks by advance. spritesheet.mov
  3. Thanks @ldd for your explanations. It's more clear. And thanks you @samme I'm gonna see this. Why do you recommend that ?
  4. @ldd , you rock ! It's works perfectly. Thanks all for your answers ! Just one question, why do I have to put some function outside of update() or create() ? I made it too for others functions but I didn't know why it didn't work inside these.
  5. Thanks you both for your answers, I'll try tonight or tomorrow
  6. Sorry for the delay (haha) ! Thanks for your answer ! Emails are added like this inside my create() function emails = level2.add.group(); emails.enableBody = true; and then inside the update() function in createEmails() function : function createEmails(mail) { var mail = emails.create(level2.world.randomX, 0, 'email'); ..... ..... } And yes I agree, passing mail in paramater is useless
  7. Yes I understand that, I tried to put it into the creatEmails() like this : function createEmails(mail) { var mail = emails.create(level2.world.randomX, 0, 'email'); mail.width = 50; mail.height = 40; // mail.name = 'mail' + x.toString() + y.toString(); // mail.checkWorldBounds = true; mail.events.onOutOfBounds.add(mailOut, this); var numY = Math.random() * 500 + 200; // Get a number between 200 and 500; mail.body.velocity.y = numY; var numX = Math.floor(Math.random() * 99) + 1;; numX *= Math.floor(Math.random() * 2) == 1 ? 1 : -1; mail.body.velocity.x = numX; setTimeout(createEmails, 2000) } but no emails are generated.
  8. I've edited my first post to add the function who call createEmails() @mattstyles I tried to put the settimeout inside the stratGame() function, on the "else", but it didn't work
  9. Yes if I write your code in my browser console I have the good behaviour. My createEmails() function was not inside the update(). I remember that when I did that, I got errors, but not now.. so I'm trying some stuff
  10. @mattstyles thanks for your answer too. I tried it but it does the same behaviour.
  11. Thanks for your answer. @Rydez I tried both methods but I have the same result : the items are generated infinitely after 2 seconds, but not one time every 2 seconds.
  12. Hi all, I'm trying to generate items randomly. For the moment it's ok, but I would like to add a little delay from every items. For exemple, I would like to find a way to generate them every 2scd. My code below : In the create() : emails = level2.add.group(); emails.enableBody = true; In update() function createEmails(mail) { var mail = emails.create(level2.world.randomX, 0, 'email'); mail.width = 50; mail.height = 40; // mail.name = 'mail' + x.toString() + y.toString(); // mail.checkWorldBounds = true; mail.events.onOutOfBounds.add(mailOut, this); var numY = Math.random() * 500 + 200; // Get a number between 200 and 500; mail.body.velocity.y = numY; var numX = Math.floor(Math.random() * 99) + 1; ; numX *= Math.floor(Math.random() * 2) == 1 ? 1 : -1; mail.body.velocity.x = numX; } function startGame(mail) { if (score >= 1000) { emails.destroy() } else if (scoreEnemy >= 1000) { emails.destroy() } else { createEmails(); } } Thanks by advance !
  13. I finally succeeded by another way. I added a group of enemies under the character , and made them able to collect falling objects. The collision between them works well.
  14. Thanks for your answer. Yes I already tried that, but unfortunately it doesn't work.
  15. Sorry to reply only now, I don't remember how, but I succeeded to do it a few minutes after, so I forgot to come back here. But thanks for your answer !