• Content count

  • Joined

  • Last visited

  • Days Won


samid737 last won the day on April 18

samid737 had the most liked content!

1 Follower

About samid737

  • Rank
    Advanced Member
  • Birthday February 12

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    The Netherlands

Recent Profile Visitors

244 profile views
  1. Hi, there is a timeline property for a tween, if you inspect it you will find many properties that you can tweak to achieve what you want: For your case, here is an example of how you can update the tween during play: You could easily adapt it to your scale ratio. Note that you also have to recalculate your new duration,otherwise it will run sort of fast forward to the new position. Also the tweenCondition I provided is position changing, but you can specify what you want to achieve (alpha change, scale change etcc)...
  2. Oke then you should just check for collision within the if statement: if (this.cursor.up.isDown && this.player.body.touching.down&& (game.physics.arcade.collide(this.player,this.grasses)||game.physics.arcade.collide(this.player,this.branches))){ this.player.body.velocity.y = -600; } else if (this.cursor.right.isDown){ this.player.body.velocity.x = 300; } else if (this.cursor.left.isDown){ this.player.body.velocity.x = -300; } else { this.player.body.velocity.x = 0; }
  3. The cause is found in the input logic you provide in your update function: if (this.cursor.up.isDown && this.player.body.touching.down){ this.player.body.velocity.y = -600; //delete this line if you dont want the bounce } else if (this.cursor.right.isDown){ this.player.body.velocity.x = 300; } else if (this.cursor.left.isDown){ this.player.body.velocity.x = -300; } else { this.player.body.velocity.x = 0; } Judging from the code, it looks like the bouncing when touched is exactly what you wanted in the first place?.You are telling Phaser: if I am holding the up key and the lower part of my body (belly) is being touched, then add velocity in -y direction/bounce up, which is true when you hit a firefly while holding the up key. If you want the player to go up only when you press up (so no bounce): if (this.cursor.up.isDown){ this.player.body.velocity.y = -600; } if (this.cursor.right.isDown){ this.player.body.velocity.x = 300; } else if (this.cursor.left.isDown){ this.player.body.velocity.x = -300; } else { this.player.body.velocity.x = 0; } Is this what you were trying to achieve? Let me know if you can't work out what you are trying to achieve
  4. Hi, although your code is not in English, which is recommended to do in the future if you post on this forum(for readability), it is structured well enough to understand. You have many possibilities in doing this within Phaser: If you want to play using four keyboard keys, then you could do the following: -add four dummy sprites//rectangles that serve as collision boxes and position them below your guitar line. -add four sprite groups ( ) in the create function, one for each color. Add each boule to the corresponding group when it is created (in crea_sprite functions): function crea_sprite_bleu() { //... yes thats correct they are bleu_boules.... and nooo the size of the group is not fixed to two bleu_boule_group.add(boule_bleu_rand); -check for overlaps in the update function and add an overlapCallback to it: game.physics.arcade.overlap(blue_boules_group, blue_boules_dummybox, blueIsBelowLine); game.physics.arcade.overlap(green_boules_group, green_boules_dummybox, greenIsBelowLine); .. .. -you have 4 colors, so 4 inputs in the update function and you for example return a boolean from the blueIsBelowLine callback to check if it is overlapping: if (game.input.keyboard.isDown(Phaser.Keyboard.D)){ //if blueIsBelowLine //add score } if (game.input.keyboard.isDown(Phaser.Keyboard.A)){ //if greenIsBelowLine //add score } if (game.input.keyboard.isDown(Phaser.Keyboard.S)){ //.. } if (game.input.keyboard.isDown(Phaser.Keyboard.W)){ //.. } But the easiest way out without any collision checking is to make the same four groups. You can then specify the distance required to give a score(the closer the better for example): if (game.input.keyboard.isDown(Phaser.Keyboard.D)){ if blue_boule_group.getChildAt(-1).y>500&&<blue_boule_group.getChildAt(-1).y<600){ score+=1; // bit far off } if blue_boule_group.getChildAt(-1).y>=600&&<blue_boule_group.getChildAt(-1).y<700){ score+=5; //right on spot } } if (game.input.keyboard.isDown(Phaser.Keyboard.A)){ if green_boule_group.getChildAt(-1).y>500&&<green_boule_group.getChildAt(-1).y<600){ score+=1; // bit far off } if green_boule_group.getChildAt(-1).y>=600&&<green_boule_group.getChildAt(-1).y<700){ score+=5; //right on spot } //...... } if (game.input.keyboard.isDown(Phaser.Keyboard.S)){ //..... } if (game.input.keyboard.isDown(Phaser.Keyboard.W)){ //..... } If you are using the mouse or touch to play: One way to achieve what you want is to add the boules to a group and enable input for each child in that group, a nice example: var boule_group; //in create; boule_group.inputEnableChildren = true; Then in your "boule" creation functions you add those boules to the group, listen to mouseclicks and execute a function when a boule is clicked: function crea_sprite_bleu() { //... boule_group.add(boule_bleu_rand);, this); } Then you can make a function called clickSprite that adds the score and does everthing you want: function clickedSprite(object){ //if the boule is below your line add the score console.log(object); score++; } VoilĂ ! Another way of doing this, since you are using arcade physics is to make a dummy sprite that follows your mouse (dummysprite.x= game.input.activepointer.x) and in your update function check for overlaps between the boule_group and your dummysprite: Hope this will help you make the deadline!
  5. One way might be to dissect the area of the game manually via switch statements, and check if the mouse pointer lies within a certain range (x,y) and assign the appropriate column/row directly but thats inconvenient if you want a bigger board size. Another possiblity might be to create two groups that contain sprites (X and O).You correctly position each sprite(two nested for loops), enable input to listen to mouseclicks, but set their alpha to zero to hide them. You can add a custom property to each sprite within the most inner for loop: ROWNUMBER and COLUMNNUMBER . Then, if the corresponding player clicks, set either X or O sprite alpha to 1, get corresponding COLUMNNUMBER and ROWNUMBER and continue with your algorithm. Another, maybe more convenient way (maybe not) : Here is an example of a tic-tac-toe game concept purely based upon collision checking (without physics). You can quickly alter the size of the board using this method. Here is the codepen: Basically, you make a group of sprites and a group of hidden (green debug rendered) lines that you use for intersection calculation. Then after each player clicks on his board, it will "notify" any line that intersects with the sprite in that board and mark it. So you are keeping track of the intersect counts that each player has with each line, and if its a winning combination(for example: LINE_ROW2.intersection_list.filter_To("player2").count==3), then you have a winner. Also, since the number of possible "win lines" are 2*boardsize+2*diagonal lines., you can adjust the board size to any dimension. It does not directly answer your problem, but it might give you more ideas on how to approach it within Phaser. Its probably not the standard, quickest/most efficient algorithm, but its an interesting way of demonstrating the usefulness of collision detection. Also using this approach will allow you to retrieve any property you mentioned, such as mouse position (in the collisionCheck function). You can use the pointer object to retrieve the x and y position of your mouse when you click a certain area:
  6. phaser

    It looks like a fun game! It took me 2-3 plays to get used to it so thats alright and its kind of fun to dunk using your finger. My only suggestion is to maybe add an " instruction finger" animation that moves along with the green arrow instruction. Sort of like this one:
  7. here is an example of how you can reset the same tween without adding a new one: The key parameter that determines where the tween continues is found in the timeline property of the tween : tween.timeline[0].dt . If you reset that to 0 it will start from the beginning. The example has a bit more features where it resets the tween when pressing the A button. However, its more tedious to work this way and the simplest way out is to add it again, but if you really require the same tween then this could be a solution.
  8. The reason why that is happening is you are setting your velocity to zero when you are on the platform, but the platform also has 0 velocity. This is because your tween is directly adjusting the x, without considering physics. Then you are jumping and you both have zero velocity so it goes perfectly up. If the platform did have velocity then it would not behave this way. Here is an example of how it would look like if you tween the platform its velocity: An alternative is let the player his x equal to the platform its x value when it is on the platform, but that would make him stick to the platform, so thats not really nice.
  9. If you create a group, the group itself will also have a world transform, thats the reason why it will rotate about the group its position. You could iterate trough each saw and rotate them individually: this.saws.forEach(function(saw){saw.angle+=1}); An alternative is to try to add a tween animation that rotates objects and add it to each saw. Here is an example of both situations you can adjust in the script: The example assumes that you do not want to rotate the bodies (it would be a bit pointless for the saw).
  10. checkWorldBounds can be expensive if you have many objects: Maybe you can disable that feature and test if it makes any difference in performane. If it does try to make your own custom walls that destroy the bullets on collision?
  11. It could be Im not sure about what happens internally when you add a filter in Phaser. But if you stick to one sprite that would be ideal and you can always test it if you do use it for multiple sprites that is the good part. Its like when you add a sprite to the world it probably has a default filter applied to it, so you are doing the same thing, just with another filter I would say?
  12. Here is an example of something you could use: The source code is from here , its probably the one you are referring to: basically I "hacked" my way into the fragment shader by eliminating the time dependency of the cosine and sine functions that are used to "rotate" the hue. I replaced them by a parameter/constant angle (in degrees) that you can pass to hueRotate.init. The angle you provide determines the new color, so you could for example define some angles/colors you like and update things when necessary? (I want blue --> pass 30 degrees , red --> 180 degrees etc.for .). The sprite was originally blue by the way (at 0 degrees). You also have to assign the right sprite properties in the init function, but you can probably organize the structure of the code better to make it fit for use in your own game? I am not sure what performance implications are when adding you own custom filter within Phaser. Here I added 1 additional uniform float and even removed the dynamic coloring within the fragment shader.... My reasoning is also that this way you don't have to let the CPU do any matrix computations via the colorMatrices you mentioned, just let the fragment shader (probably the GPU then??) do the calculation by multiplying matrices by the two constants (the sin and cos), so I would say that it should be less expensive than the original shader.
  13. Hmm, its still kind of strange to me, because of this for example will give the same results: var Obj= { foo: "bar", log: function() { var selfie = this; console.log("external function: = " +; console.log("external function: = " +; console.log( ===; (function() { console.log("internal function: = " +; console.log("internal function: = " +; console.log( ===; }()); } }; Obj.log(); You could use any naming right? But it does have some special feature in the web API when looking at your first link.
  14. Hi no problem its something I was also stuck with. again I never seen anyone use self. Is there any reason for it? Especially: var self = this; Why not just stick to this?
  15. Looks fantastic! Especially the bullet effects look great (the magic worked I guess). Good luck with the release!