symof

Members
  • Content Count

    156
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by symof

  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. symof

    If velocity than

    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. symof

    If velocity than

    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/
  16. I would only worry about asset theft once that actually happens. If you're a small indy guy/girl then adding encryption to your files on the off-chance that someone might steal your stuff is nonsense, and adds to code complexity. My first priority would be coding the complete game in a manageable time-frame, and then marketing. By far the biggest hurdle, that I think indy devs have, is the marketing part, since from the onset this is a market PUSH from you to try selling it to someone that does not need it, or simply having someone play a game that you liked making. A market PULL would be when there is already an existing DEMAND for you game such as gold/platinum versions or sequels of the game. As for using a native wrapper... You are again over-complicating things. And I will explain why. The current direction of HTML5 on Android devices is to create Cloud Apps that can be linked into the Home Screen without downloading resources on the client device(no more then a JIT Browser would download during web browsing). You can read more on this from the google chrome dev pages at https://developer.chrome.com/multidevice/android/installtohomescreen Now what this means is that you would no longer require a wrapper at all, since any HTML5 App that is distributed in the cloud will be available from the home screen. What this means in turn is that all your assets will initially be hosted on your webserver then sent to the client, so your full source code will no longer be available for download and disassembly, however disassembly will happen regardless of the amount of protections you put in place. What you are doing in essence is making it harder for someone that does not have sufficient experience to just copy-paste your full app and distribute it as their own. So in the case of clouds apps and current development direction your best bet at hindering the copying process or re-host of files is to either do a urlencode for the assets that you use so that it is only available from the app. OR Use .htaccess to hinder direct links such as http://stackoverflow.com/questions/7127153/php-how-can-i-block-direct-url-access-to-a-file-but-still-allow-it-to-be-downl https://docs.joomla.org/How_do_you_block_direct_hot_linking_to_image_files_using_htaccess%3F OR My personal favorite. URL locking. if(document.URL.indexOf("domain.tld") != -1) { //found } else { //nope } This checks if the string "domain.tld" exists in the current URL address bar. And then does stuff based on that. So you could redirect it to your homepage if the script is not on your website. Or maybe write an alert. I wrote this handy fiddle for a more in-depth example: https://jsfiddle.net/Lnbos3ns/ Frankly I wouldn't bother with any of these unless you actually find yourself in the position of losing revenue due to stealing. I personally have not yet done this for the apps that I have published, nor do I intend to do so, unless it becomes a genuine issue such as potential bandwidth theft, or hogging resources, that raises the cost for me. Hope this helps.
  17. Great work! I enjoyed playing this game you made. The only issue that I had was with the sound being a bit too loud, but that might have been from my machine.
  18. symof

    aMazeBall

    I made a new version of this based on ad revenue. https://play.google.com/store/apps/details?id=com.cadsotic.aMazeBallfree It uses Leadbolt as the ad network. So far I got 2 clicks which are my own XD
  19. Game is now up on Google Play store https://play.google.com/store/apps/details?id=com.cadsotic.Axhogenfree It uses Leadbolt as the ad network and Cordova as the wrapper.
  20. Assuming you are trying to create a 2d array (matrix) then you need to follw these steps, 1. We declare it as a variable. var grid_9x9 = [ [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], ]; 2. We create another function that can display or array. This function should take in an array as parameter. function Render2dGrid(arr){ for(var row = 0; row < arr.length; row++){ for(var col = 0; col < arr[row].length; col++){ if (arr[row][col] != 0){ //value is 1, render the cell }else{ //value is 0 do not render cell } } } } 3. We need a function to set the values inside a Rectangle to 0 ( 1 is visible, 0 is not visible). O(x,y) will be the start value and E(x,y) will be the end value of the rectangle selection. function Toggle2dGrid(arr, ox, oy, ex, ey){ var temp; //we normalize our Origin and End values if ox > ex then { temp = ox; ox = ex; ex = temp; } if oy > ey then { temp = oy; oy = ex; ex = temp; } //the if statement checks that our endpoints are not values outside out array range. if ((ox != ex) && (oy != ey) && (ey <= arr.length) && (ex <= arr[row].length) && (ox => 0) && (oy => 0)){ for(var row = oy; row < ey; row++){ for(var col = ox; col < ex; col++){ //set value to 0 arr[row][col] = 0; } } else { //Error selection console.log('Error selection'); } } In actual use, you first Initiate it, then render it, then toggle, then render.
  21. I am looking for a way to achieve this effect in phaser with the inbuilt tilemap render: http://codeincomplete.com/games/tower-platformer/#flat This is what I found in the examples http://phaser.io/examples/v2/world/world-wrap However the world wrap is not very fluid, since when you go from the right to the left then the image just snaps on screen. The only other topic that I have found simlar to what I want is this: And it unfortunately has no solution. I can obviously achieve this outside of phaser but... Can I do it in phaser? Or can I at least come close to it? I am expecting something better then the world wrap example. Any ideas?
  22. This is part of the examples. http://phaser.io/examples/v2/loader/load-events Your other option would be to use states. http://phaser.io/news/2015/06/using-states-tutorial
  23. What you are looking for is game.scale.fullScreenScaleMode = Phaser.ScaleManager.EXACT_FIT; http://phaser.io/examples/v2/display/fullscreen When using Phaser.ScaleManager.SHOW_ALL if the client screen is smaller then the base screen then the scale will be reduced in order to show all. If the client screen is larger then the base then it will do nothing as the client already sees everything on screen. EXACT_FIT does exactly as the name suggests, it takes ANY base screen and fits it EXACTLY to the client display, this in turn will cause severe transformations if for example the base screen is made for a wide display 16;9 of 1024x576 to 800x600 for instance as the width will be smaller by 224 px and the height will increase by 24px causing skewing for the whole screen. As a side note. 1024 x 576 is a bad display to set your base at because of the 576 height. My choice would be either 1280 x 720 or 960 x 540 as they will give a more crips look on modern devices. https://en.wikipedia.org/wiki/Graphics_display_resolution The 576 height is part of what is considered SD https://en.wikipedia.org/wiki/Standard-definition_television
  24. Neatbeans has a really powerfull debug suite as far as javascript goes. https://netbeans.org/features/html5/index.html You can also do usb debuging right into android from the ide in real time without the need to upload to a custom server. It also features plugins. http://plugins.netbeans.org/PluginPortal/ http://plugins.netbeans.org/plugin/49666/js-css-minify-compress
  25. You could also consider http://atomicgameengine.com/ it used to be paid but it changed to MIT in recent months, however their documentation is lacking. You should also consider netbeans IDE for javascript https://netbeans.org/ . I personally use netbeans and I am very satisfied with it and it's autocomplete feature.