defic

Members
  • Content Count

    13
  • Joined

  • Last visited

  1. Hello everybody! I would like to present my first Phaser game (and also kinda my first game ever ) I made as a school project few months ago. Simple arcade game where you have to get the basketball go through the hoop. I also made leveleditor with phaser so making levels would be easy, and the levels are saved in json-files. The progress is saved in localStorage. I haven't really developed it more lately, and the main reason is that I could not figure out why (physics contact) sound is delayed on android devices. I tested it with chrome for android and also with CocoonJS. Maybe listening to contact events just eats too much performance? On iPad it seemed to work fine. On the photo I attached you can see the game and level editor in the background. Please test it and tell me what you think of it . And btw he levels are not in balance as you can't get all 3 stars on all levels. You can find the game here: http://jkuitunen.fi/koripallo/
  2. defic

    p2 Contact impulse

    Thanks, this helped me a lot. Though I edited the code little bit to calculate the difference between the velocitys of the colliding bodies: var res = Phaser.Point.distance(new Phaser.Point(equation[0].bodyB.velocity[0],equation[0].bodyB.velocity[1]), new Phaser.Point(equation[0].bodyA.velocity[0],equation[0].bodyA.velocity[1]));console.log(res);So if we have 2 moving objects and they are f.e. free falling and slightly touching each other,the impact would not generate a sound.
  3. I wanted to make slow motion physics effect by changing p2 framerate from the default 1/60 to 1/120 or even 1/240. It looks fine when objects are airborne but as soon as they need to bounce off of something it seems like the restitution is way lower than it should be. is it a bug or is there something i have missed?
  4. Solved the issue by creating my own timer and adding timed events to it like so: // at createthis.customTimer = this.game.time.create(false);this.customTimer.resume();this.customTimer.running = true;...pauseOn : function(){ this.pauseMenu.show(); this.customTimer.pause(); this.physics.p2.pause = true;},...pauseOff : function(){ this.pauseMenu.hide(); this.customTimer.resume(); this.physics.p2.pause = false;}....//inside object which is using timerthis.game.customTimer.add(Phaser.Timer.SECOND * moveInfos[index].timetomove, this.moveToPoint, this);//I hope people find it useful
  5. I want to be able to tween my pause menu when I hit pause, but it seems that if game.pause = true, tweens do not work anymore. My game is p2 physics based, and I got around the problem py using game.physics.p2.paused. All was fine, but now I am using timed events for kinematic objects, and it is not working properly anymore (as the time keeps running in the background while game is 'paused'). I have my timed events like this: this.game.time.events.add(Phaser.Timer.SECOND * moveInfos[index].timetomove, this.moveToPoint, this).autoDestroy = true; So is it possible to pause the game and still be able to have tweens, or another way to solve this problem would be to individually pause all user setted timed events? Is there an array of timeouts set by the user somewhere to be find? Or is this possible yet?
  6. Great thread. I am working on a game and I was thinking about releasing it as web app and also on iOS and android. I have tried my game on android and it works great with cocoonjs (canvas+). However, I do want to use facebook leaderboards for my game and I have not done anything like this before. I would appreciate if I did not have to do the same thing for 2 times because of the different platforms. Could anyone give some advices? Can I implement facebook integration in plain javascript so it would work on any wrapper and also with web? Rich said in cocoonjs thread that cocoonjs would become unnecessary with iOS 8, as phonegap would outperform it. But for android, cocoonjs still seems to be the only viable option. TL;DR: how to implement facebook leaderboard with the least amount of work for all platforms? Android: using cocoonjs (cocoonjs plugin?) iOS: Phonegap (phonegap plugin) if rumours are true OR cocoons (cocoonjs plugin?) web app: https://developers.facebook.com/docs/games/canvas/canvas-tutorial (?) By the way I am using web fonts with cocoonjs wrapper and I haven't had any issues.
  7. Okay this might be a ridiculous question, but is it possible to save the state of the current state, so I could easily continue where I left off. Let me explain a bit more. At the moment I have a level editor (made with phaser) in my game and it outputs json so I can easily save the levels to external file. But when I test the level by playing it, I cannot go back to the editor (unless I do a json parsing module for the editor, which would require too much work for atm). So can I save the state using phaser libraries or plain javascript? Edit: Maybe one way to do it: never leave the level editor and just launch a new window with the new level? And I would like to add that the level editor is just for developing the game, so no worries about users and "bad performance" Edit2: okay got it working like described above. It ain't pretty but it is working. Funny how I was banging my head a while trying to figure this out and as soon as I write the question here I start progressing . Here is how I did it: //at editorlevelinfo = this.json;var w = window.open("url to my game");//after loading my game in new windowif(window.opener != null){ if(window.opener.levelinfo != null){ var json = window.opener.levelinfo; this.state.start('Level', true, false, json, null); }}else{ this.state.start('LevelMenu');}
  8. When phaser button is pressed and the input is released outside of the button, the button is still considered as pressed in phaser. The traditional way to handle this would be that the button is only consiredered as pressed if the touch begins and ends in the area of button. This is the way user can cancel pressing the button if he/she so desires by moving the finger/mouse somewhere outside of the button area, but at the moment this is not possible. This is the way I am currently using buttons. Is there another way to do this, so it would work like i would want it to? this.button = this.game.add.button(0,0, 'level_button', function(){ console.log("button is pressed");},this);I am using 2.20 RC2 at the moment, but it has worked like this since I started with phaser (2.0.7). You can see the same behaviour in phaser examples, f.e. in this: http://examples.phaser.io/_site/view_full.html?d=buttons&f=action+on+click.js&t=action%20on%20click
  9. old topic but i still experience this with Chrome. It only occurs when there is not much going on on my scene. In my game, if only 1 ball is bouncing, it looks like it is stuttering even though fps is solid 60. If I throw multple balls, stuttering stops and it is more fluid. I also experienced this kind of behaviour with chrome's requestAnimationFrame on a simple canvas animation and I suspect that that is causing the stuttering here also. The effect is even worse with new phaser rc 2.2.0. And btw I am using P2 physics also.
  10. Thanks for the explanation However, I am still having hard time understanding the "prototyping vs precached functions". Here is an example of my code: BallObject = function(game, x, y) { Phaser.Sprite.call(this, game, x, y, 'basketball'); this.game.physics.p2.enable(this); game.add.existing(this); this.body.setCircle(31); this.body.mass = 10; this.body.damping = 0.0; this.body.data.gravityScale = 1; this.inputEnabled = true; this.events.onInputDown.add(function(){ game.ball = this; game.touchdown = true; }, this); this.events.onInputUp.add(function(){ game.touchdown = false; this.launch(this.getLaunchForceX(),this.getLaunchForceY()); game.firstBall = false; }, this);};BallObject.prototype = Object.create(Phaser.Sprite.prototype);BallObject.prototype.constructor = BallObject;BallObject.prototype.launch = function(Xvelocity,Yvelocity){ this.body.velocity.x = Xvelocity; this.body.velocity.y = Yvelocity;};BallObject.prototype.getLaunchForceX = function(){ return -(game.input.x - this.x) * 5;};BallObject.prototype.getLaunchForceY = function(){ return -(game.input.y - this.y) * 5;};The code is just for throwing basketballs. How should I to change the code to gain better performance (precached functions)?
  11. Please do write one. I am interested in this topic and I don't have a lot of experience with Phaser or javascript in general. What does GC mean? also I used this https://github.com/tutsplus/Monster-Wants-Candy-demo for a reference when I was figuring out how to implement states and it is using prototyping. Is this bad? What does precached function mean?