symof

Members
  • Content count

    156
  • Joined

  • Last visited

  • Days Won

    1
  1. Go to this webpage on your smartphone www.goodboydigital.com/pixijs/benchmark/ Keep your input(finger) pressed until the frames drop bellow 30 fps. Share your results. If it's bellow 30fps from the start... Then pixijs does not support that graphics chipset properly. I attached 2 screenshots, - my smarphone Moto g3 3rd generation with Android 6.0.1 - with an astounding 17800 bunnies! - my desktop Dual-Core Pentium G4400 @3.30 per core, with a NVIDIA GT 1060 3Gb. Windows 7, DirectX 11 - with 184,000 bunnies!
  2. So I'm gonna disseminate his code a bit , since his question has been answered anyway var self = this; this.stage.disableVisibilityChange = false; game.add.text(20, 20, 'Level 1', { font: "20px Arial", fill: '#ffffff'}) Now in his current scope "this" refers to the "game" object so what happens here is var self = this; "self" becomes a copy of "this" so in essence it works as a pull request to work on local content. This is good in cases where you don't wish to alter the values in the original, but you want to modify them in your current instance and then dispose of them. this.stage.disableVisibilityChange = false; Using "this" here, modifies the original reference permanently. So in all future uses across the application from now on this value will persist unless changed "game.stage.disableVisibilityChange = false;" game.add.text(20, 20, 'Level 1', { font: "20px Arial", fill: '#ffffff'}) Could have been written as this.add.text(20, 20, 'Level 1', { font: "20px Arial", fill: '#ffffff'}) And it will have the same effect of permanently altering the "game" object". self.weapon = game.add.weapon(30, 'weapon'); self.weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; self.weapon.bulletAngleOffset = 90; self.weapon.bulletSpeed = 400; self.weapon.fireRate = 200; self.weapon.fireAngle = Phaser.ANGLE_RIGHT; can be written like so self.weapon = this.add.weapon(30, 'weapon'); self.weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; self.weapon.bulletAngleOffset = 90; self.weapon.bulletSpeed = 400; self.weapon.fireRate = 200; self.weapon.fireAngle = Phaser.ANGLE_RIGHT; So from this point onward in the current "game state" a weapon is added to the global view, so game.add.weapon(30, 'weapon'); Is again a permanent addition to the game object. BUT ! Everything else is not permanent. So all the configs for self.weapon are only available in this "game state" (this is not a real game state but I have no better way of referring to it) and should the state change, the configs will be lost. self.player = this.add.sprite(50, 300, 'user'); self.player.angle = 90; self.player.alpha = 0; So here again. A sprite is added with "this" to the "game" object. The sprite will be available globally from the "game" object but if refered to from outside the "scope" of the "game state" then the configs for it will be reset. So if you try and access the "player" sprite it will not have "alpha = 0" and "angle = 90" So basically after he changes the "game state" the only changes left will be this.stage.disableVisibilityChange = false; game.add.text(20, 20, 'Level 1', { font: "20px Arial", fill: '#ffffff'}) game.add.weapon(30, 'weapon'); this.add.sprite(50, 300, 'user'); game.add.tween(self.player).to({ alpha: 1 }, 1300, Phaser.Easing.Linear.None, true); this.input.keyboard.createCursorKeys(); this.input.keyboard.addKey(Phaser.KeyCode.SPACEBAR); or this.stage.disableVisibilityChange = false; this.add.text(20, 20, 'Level 1', { font: "20px Arial", fill: '#ffffff'}) this.add.weapon(30, 'weapon'); this.add.sprite(50, 300, 'user'); this.add.tween(self.player).to({ alpha: 1 }, 1300, Phaser.Easing.Linear.None, true); this.input.keyboard.createCursorKeys(); this.input.keyboard.addKey(Phaser.KeyCode.SPACEBAR); or game.stage.disableVisibilityChange = false; game.add.text(20, 20, 'Level 1', { font: "20px Arial", fill: '#ffffff'}) game.add.weapon(30, 'weapon'); game.add.sprite(50, 300, 'user'); game.add.tween(self.player).to({ alpha: 1 }, 1300, Phaser.Easing.Linear.None, true); game.input.keyboard.createCursorKeys(); game.input.keyboard.addKey(Phaser.KeyCode.SPACEBAR); In essence freeing the resources that were in use by "self" and whatever config/assets it contained exclusively.
  3. Yes you can use any naming, the way he uses it holds no special meaning, he could have written it as anything and it would made no difference in his current code. var self = this; var this = this; let self = this; var sf = this; var thiz = this; var p = this; But ! "self" is a global operand, so it's scope is pretty much like "this" noadays(and no they are not the same thing but very similar in some aspects), so he should change it to something else such as "-this" and not "_this" since "_" is also used sometimes to declare variables that are in the global scope. Now this is not to say that his code won't work this is more of a cross-language thing. So even if his code works in Javascript, if someone with pure Python programming comes along to learn javascript and see's his code, that person will have a brain meltdown trying to figure it out.
  4. That must be it since I have MVPS hosts http://winhelp2002.mvps.org/hosts.htm on all my machines. Which is kinda like an add blocker.
  5. var Obj= { foo: "bar", log: function() { var self = this; console.log("external function: this.foo = " + this.foo); console.log("external function: self.foo = " + self.foo); console.log(this.foo === self.food); (function() { console.log("internal function: this.foo = " + this.foo); console.log("internal function: self.foo = " + self.foo); console.log(this.foo === self.food); }()); } }; Obj.log(); https://jsfiddle.net/caxjvLL0/ Well Initially I wrote a longer post but I kinda deleted it when I wrote the code (Ooops!). But the shorter version is that, "self" is mostly used by typescript enthusiasts to keep the scope of the variables in check. Nowadays "self" is also a global keyword like "this" so he shouldn't really be using it like this anymore, since it gives me headaches ( :sad:) https://developer.mozilla.org/en-US/docs/Web/API/Window/self http://stackoverflow.com/questions/962033/what-underlies-this-javascript-idiom-var-self-this
  6. Good game. Loved playing it for around 10 minutes. No clue how it is in 100 players but 1v1 is bad, especially if someone is already with a fully upgraded ship. On my machine I had to refresh the website everytime I died since after pressing play again, all I see is "please wait" greyed out. A few things I think it would improve in the game. 1. Add some base income even without having any satelites. 2. Have the satellites start at level 1, so they can shoot a bit, this was people can hog the satelite to get upgrades if they just spawned. 3. Movement speed shouldn't be upgrade-able. Everyone should have the same speed with a speed power-up to go faster. This as #2 is mostly because in 1v1 there is no way to outrun or live enough to get other upgrades to fight back. 4. Have the map/teams reset if a team captures 80% or more of the satellites or if one of the teams does not capture a satelite for some time(maybe 15-30 minutes 5 minutes) But yeah... Those need fixing IMO.
  7. Using Phaser is fine. (hint : the secret word is : phaser) https://jsfiddle.net/cwLfqu0x/3/
  8. I thought maybe I should clarify further. This contains some extracts from https://en.wikipedia.org/wiki/Apple_A7 "Apple states that it is up to twice as fast and has up to twice the graphics power compared to its predecessor, the Apple A6." What this means is that the GPU for A7 should render twice as fast and the older A6, but since you are saying that you get exactly half of 60fps, that leads me to believe that pixi does not properly support 64 bit chipsets or at least the Apple 64 bit chipset. And frankly some of the 64 bit android smartphones are not that widely used. So I dunno. I'm kinda grasping at straws but in essence. If the 64 bit chipset has runs at exactly 30fps, half of the optimal 60fps , that leads me to believe that only half of it's capability is being used.
  9. @samid737 The difference here is in the chipset that they are using. iPhone 5C uses Apple A6 The Apple A6 is a 32-bit package on package (PoP) system on a chip (SoC) iPhone 5S uses Apple A7 The Apple A7 is a 64-bit system on a chip (SoC) So this might be a PixiJS issue. And i'm sorry to say I don't really know that much on how pixi works? Maybe @rich can offer some insight on this?
  10. Generally speaking WEBGL and webview will work best on new smartphones. So it does depend on your project needs. There are other alternatives to phaser such as https://crosswalk-project.org/ You might also try to edit the css of the div you are using #game-area { margin : 0; padding: 0; transform: translate3d(0,0,0); -webkit-transform: translate3d(0,0,0); } This triggers the WEBGL before you actually try to run Phaser. It's a simple hack to trigger it since javascript use JIT compiling. It's kinda like saying to Javascript "hey i'm gonna use webgl on this page, initiate the API now). So just experiment. Try to turn WEBGL on and off and see what works best for you.
  11. do: function(objects){ objects.body.velocity.x *= -1; } So if body.velocity = 50, on collion it would be 50*-1 = -50, then if it collides again its -50 * -1 = 50. The issue was that you were setting //set speed to 50 element.body.velocity.x = 50; inside the collision handler . so it's always going to start at 50. You need to set the velocity outside of the collision handler and simply reverse it when it collides. Or use the bounce function that @samid737 provided as an example.
  12. My guess would be that you are using Phaser.WEBGL or Phaser.AUTO that defaults to Phaser.WEBGL when you create the game object, using Phaser.CANVAS might solve that. var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'GameDiv' ); If that doesn't solve it then your issue might be with the physics and amount of bodies you have on the screen. ARCADE is best for mobiles.
  13. I wrote it so it's simple to see the process. There is no reason "domain.tld" can't be a variable that you generate on the way by doing string operations. The end goal would be to have a variable that contains the name of the url. So you can do: https://jsfiddle.net/Lnbos3ns/1/ Be Creative!
  14. Fiddle to the rescue. http://jsfiddle.net/ya22nbdr/3/ So your code should look something like this: do: function(objects){ objects.body.velocity.x = -50; } So as your "do" function is the Collision handler function you only need to get the object who's direction you want to change.
  15. I don't actually URL lock my projects as of yet. But this is how I would do it if(document.URL.indexOf("domain.tld") != -1) { //found } else { //nope } I wrote this handy fiddle for a more in-depth example: https://jsfiddle.net/Lnbos3ns/