3ddy

Members
  • Content Count

    72
  • Joined

  • Last visited


Reputation Activity

  1. Like
    3ddy got a reaction from ecv in Chat room seems to have been removed   
    chat [*][*][*]
    @rich it would be awesome to have the chat rewritten, because it was randomly kicking ppl from time to time, also there were some troubles with users list in chat, but we miss that place, even with those bugs
  2. Like
    3ddy got a reaction from Conflux in When is create function called?   
    init -> preload -> create

    https://phaser.io/docs/2.6.2/Phaser.State.html#methods you can learn more here, I think there was some Phaser StateManager ebook or smth like that and there was some nice diagram showing what is called in order
  3. Like
    3ddy reacted to samme in Child sprites updating too late   
    If possible, run `checkOverlap()` at the very start of the update, before moving any objects. That usually avoids the issue.
    Otherwise, you can call `updateTransform()` on the moved objects (or its ancestors; I'm not sure) before testing the overlap. 
  4. Like
    3ddy got a reaction from JesusJoseph in Phaser with External Font (Tamil TTF)   
    Are you trying to use that font in the beginning of body section? If yes and it still don't work maybe your game is launching faster than browser loading font - try to make some delay before using font ingame
  5. Like
    3ddy got a reaction from JesusJoseph in Phaser with External Font (Tamil TTF)   
    Hello, try to preload the font before using it in-game (just write some dot not visible on the screen before creating Phaser game). I use the code below:

     
    <style type="text/css"> @font-face { font-family: 'SlimJim'; src: url('assets/slim-jim/SlimJim.ttf') format("truetype"); } body{ background: #000000; padding:0px; margin:0px; } .fontPreload { font-family: 'SlimJim'; position:absolute; left:-100px; } </style> and then in body
     
    <div class="fontPreload">.</div>  
  6. Like
    3ddy got a reaction from kosmoskolio in How to get current frame NUMBER (not index) - Phaser Animation   
    Maybe try to use http://phaser.io/docs/2.3.0/Phaser.Animation.html#onUpdate and create some counter. When counter reaches animation length then reset it and count again.
  7. Like
    3ddy reacted to drhayes in Boss Movement Method   
    The problem is in this line:
    this.multiBlueBirdFlight = this.game.time.events.loop(Phaser.Time.SECOND * 8, this.flyBlueBird(), this); You're not saying "here is the name of the function I want you to call", you're saying "run this function right now and pass its result to the timer". You probably meant "this.game.time.events.loop(Phaser.Time.SECOND * 8, this.flyBlueBird, this);" Notice how there aren't parenthesis after this.flyBlueBird? That means you're passing the name of the function, not the result of the function. Does that make sense?
  8. Like
    3ddy reacted to Shana in Problem with shaking the camera   
    Ok, alright. I set world bounds, and then I shake the camera manually and now it works fine
  9. Like
    3ddy got a reaction from WombatTurkey in [Suggestion] - BBCode Text   
    Yay!
  10. Like
    3ddy reacted to WombatTurkey in [Suggestion] - BBCode Text   
    I was playing around with text and kind of had a light bulb moment. This might be a future feature planned for Lazer maybe? Not really sure, but I think the ability to use bbcode inside text would be an incredible addition to either one. 
    For example:
        var style = { font: "bold 12px OpenSans", fill: "#fff", align: 'center', bbcode: true};       text = game.add.text(0, 0, "Hello Phaser, I support [b]bold[/b] and [i]italic[/i] text  along with [url="http://google.com"]links[/url] and other [s]goodies[/s]", style); What's everyone's thoughts on this? Yay or Nay?
  11. Like
    3ddy reacted to mattstyles in Preload - only loading or also downloading?   
    Nope, it'll be loaded when you ask for it, the browser will not attempt to evaluate the JS (or the HTML, I dont think) to preload any necessary assets that may be needed some time in the future.
    HTTP2 will work slightly differently and your server will actually be able to push assets at the browser that it knows (or thinks) will be needed later but for now, for most people, if you want them preloaded you have to handle that yourself. Most preloaders work by initiating requests, which then get cached so that when you request them later, when you actually want them, they come from cache.
  12. Like
    3ddy reacted to Str1ngS in Preload - only loading or also downloading?   
    You're going into browser mechanics here, If the asset is not available in the browser cache, it will downloaded to your device. And depending on the cache headers/configuration set on both the client and the server each consecutive load of the same asset will be either loaded from cache(prefered) or downloaded.
    This article goes a bit deeper into browser caches: https://gtmetrix.com/leverage-browser-caching.html
    As for Phaser itself, apart from the asset having a different HTTP status code (HTTP 304 instead of 200) the asset will be loaded into memory for the current session, and you'll notice no difference (apart from loading speed).
  13. Like
    3ddy reacted to LTNGames in How do you separate your game logic?   
    I like to do what Wombat does, I separate and organize my code a lot, instead of having large functions I like to split them up into smaller ones. So instead of having a huge function with nested if statements for my player movement I'll separate them into a more organized format, it makes it easier to read and debug. As other posters have mentioned though as long as everything is readable to you or if you have a team then them as well, then don't worry too much, just remember to have fun. A few examples, I did not like the fact that I had to enter in a filepath for each asset I loaded so I made static classes to handle them.
    // Preload Functions - With pre-set directory Game.ImageManager.loadPicture = function(refrence, filename){ Game.Phaser.load.image(refrence, 'img/pictures/' + filename); }; Game.ImageManager.loadSystem = function(refrence, filename){ Game.Phaser.load.image(refrence, 'img/system/' + filename); }; Game.ImageManager.loadCharacter = function(refrence, filename){ Game.Phaser.load.image(refrence, 'img/characters/' + filename); }; It saves time, and if I ever change the directory of my assets I can simply change the one function. Also another example, for my update function for my player, because why not, examples are good. Below is a more readable to me, I can go directly to the function that says updateJump and change whatever in there, whereas some people will throw everything in their update function and it's a total mess to read and find things.
    Game.Sprite_Player.prototype.update = function() { this.updateMovement(); //----DEBUG--------- this.game.debug.text(this.game.time.fps, 2, 14, "#00ff00"); this.game.debug.bodyInfo(this, 32, 32); this.game.debug.body(this); }; Game.Sprite_Player.prototype.updateMovement = function() { this.body.velocity.x = 0 ; this.updateDirection(); this.updateJump(); this.updateRun(); }; Game.Sprite_Player.prototype.updateRun = function() { if (this.shiftButton.isDown && this.body.onFloor()) { this.animations.play('run', 25, true); this.walkSpeed = this.runSpeed; this.isRunning = true; } else { this.walkSpeed = this.initialSpeed; this.isRunning = false; } }; Game.Sprite_Player.prototype.updateJump = function() { if (this.jumpButton.isDown && this.body.onFloor() && this.game.time.now > this.jumpTimer) { if(this.isRunning) { this.body.velocity.y = this.jumpSpeed - this.runSpeed /2; } else { this.body.velocity.y = this.jumpSpeed; } this.isJumping = true; this.jumpTimer = this.game.time.now + 750; } else if(!this.body.onFloor()) { this.playJumpAnimation(); } else { this.isJumping = false; } }; Game.Sprite_Player.prototype.updateDirection = function() { if (this.cursor.left.isDown) { this.playWalkAnimation(); this.body.velocity.x = -this.walkSpeed; this.scale.x = -0.5; //Right } else if (this.cursor.right.isDown) { this.playWalkAnimation(); this.body.velocity.x = this.walkSpeed; this.scale.x = 0.5; } else if(this.body.onFloor()) { //======Idle======== this.animations.stop('walk'); this.animations.play('idle', 15, true); } }; Game.Sprite_Player.prototype.playWalkAnimation = function() { if(!this.isRunning && !this.isJumping){ this.animations.play('walk', 25, true); } }; Game.Sprite_Player.prototype.playJumpAnimation = function() { if(this.isJumping) { this.animations.play('jump', 7, false); } };  
  14. Like
    3ddy reacted to mattstyles in Phaser.Sprite.call()   
    `.call` has nothing to do with `super` objects, nor does JS have any concept of `super` objects. `.call`, along with its sister `.apply` and cousin `.bind` can be used to invoke a function with a specific context, or scope i.e. it mutates the `this` pointer to reference whatever you want it to. It can be used with various object creation methods to smudge classical inheritance into a language that does not support it, as per Rudrabhoj's example.
    .call
    .apply
    .bind
    JS scope can be tricky and stuff like call and apply actually make it even trickier, so it is well worth reading and re-reading any examples and writing plenty of your own code to test it. Those lessons stay with you no matter which JS library you use so its never wasted time and it should be a core part of any interview for JS role, understanding scope well is that important.
    In your case `Pipe` looks like it is a constructor function, which invokes the Sprite constructor with its newly created reference and then copies over the properties from the Sprite prototype (by mutating the native Pipe protoype) and works so that you get a similar result as inheriting from a base class in classical languages (note that despite ES2015 introducing `class`, `extends` and `super` keywords, JS is still prototypal and not classical). There are gotchas with this but they usually rear their ugly heads when you set up longer prototype chains or try to merge more than one object (polymorphism or multiple inheritance).
    If you follow along with classical methodology this means that Pipe IS a Sprite object, just with some extra bits, whereas it sounds like you simply want a container for 2 sprites. If you just need Pipe to contain two sprites then create them in the constructor or attach them to `this` inside some sort of `.create` or `.init` function and they will be available from any instantiated `Pipe` objects via `this`, unless you further mutate scope.
  15. Like
    3ddy reacted to Rudrabhoj Bhati in Phaser.Sprite.call()   
    call is not specific to Phaser. It is a JS method which calls super objects' (from where you inherited) construction. Like this:
     
    "use strict"; function inherit(o){ function F() {} F.prototype = o; return new F; } var Animal = function(given_name){ this.name = given_name; this.food = []; } Animal.prototype.found = function(item) { this.food.push(item); } var Dog = function(){ Animal.call(this, "Dog"); } Dog.prototype = inherit(Animal.prototype); var Cat = function(){ Animal.call(this, "Cat"); } Cat.prototype = inherit(Animal.prototype); var tommy = new Dog(); var minni = new Cat(); tommy.found("Cake"); tommy.found("Dinner"); document.writeln("Tommy found: " + tommy.food.length + " items.<br />"); document.writeln("Minni found: " + minni.food.length + " items.<br />");  
  16. Like
    3ddy reacted to rich in Pass a property name as an argument to create group?   
    var bombs; var beasts; function doStuffToGroup(groupName) { this[groupName] = game.add.group(); ... } doStuffToGroup('bombs'); doStuffToGroup('beasts');  
  17. Like
    3ddy reacted to Cudabear in Some help with P2 physics   
    The best way to make objects collide with certain objects and not with other objects is, as you say, to use collision groups.  You can reuse them, however, so add all your "obstacle" sprites to one group, and tell that group to collide with the ball group but not itself.

    As for the second part, That's something I've been wondering myself.  I recently developed a game with P2 physics where "one-way" collisions would be extremely useful, and I solved it by making masses extremely large.  That caused some other physics bugginess that I really didn't like.  So I'm pretty stumped on that one, too.  
  18. Like
    3ddy reacted to rich in Phaser is 3 years old today!   
    Wow, how time flies!
    I posted an article about how Phaser started, and where it is headed here: http://phaser.io/news/2016/04/phaser-is-3-years-old
    And also GitHub interviewed me today too: https://github.com/blog/2148-meet-richard-davey-creator-of-phaser
    Here's to another 3 years
     
  19. Like
    3ddy reacted to jim716 in PhoneGap deploy to android device   
    Not very familiar with the PhoneGap Cloud workflow, but I've used Cordova quite a bit.
    In looking at your code, my initial suggestion would be to move the Phaser code into the onDeviceReady method (in index.js).  The 'deviceready' event is fired when Cordova and its plugins are initialized.  So in general, you'll want to wait to execute your own code until this event is fired.
    I learned to develop for Cordova with Phaser using Intel XDK, which is a Cordova IDE and cloud-build service (probably a lot like PhoneGap).  Intel XDK includes a Phaser template and does have some tutorials in their documentation - most of which should apply to Cordova in general.  Intel XDK also includes the Ripple Emulator, which runs Cordova apps in a simulated device on your PC/Mac.  Although it doesn't work with all the Cordova plugins, I found it invaluable when learning because of how quickly you can test your code.  Take a look - I'm sure you can probably use Ripple with PhoneGap as well.
  20. Like
    3ddy got a reaction from Jem Kazama in Webfonts not working   
    Thanks, it solved my problem!

    Also thanks to drhayes for your impact in my problem.
  21. Like
    3ddy reacted to Jem Kazama in Webfonts not working   
    I've heard that sometimes you have to use the font somewhere before it renders properly in phaser. Maybe try something like this?

     
    <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Tangerine"> <style type="text/css"> body{ font-family: 'Tangerine'; font-size: 32px; background: #ffffff; padding:px; margin:px; } .fontPreload { font-family: 'Tangerine'; position:absolute; left:-100px; } </style> <script src="phaser.min.js"></script> <script src = "js/preload.js"></script> <script src = "js/intro.js"></script> <script src = "js/office.js"></script> </head> <body> <div class="fontPreload">.</div> <script type="text/javascript"> var game = new Phaser.Game(960, 540, 'PHASER.WEBGL'); game.state.add('Preload', MyGame.preload) game.state.add('Intro', MyGame.intro); game.state.add('Office', MyGame.office); game.state.start('Preload'); </script> </body> </html>  
  22. Like
    3ddy got a reaction from Daria K in Timer at beginning of state   
    Hello,
    I'm not a pro, but I would initialise some timer in init function to 0
    this.timer = 0;
    Then, in update function I will increment it using
    if (this.timer >= 1000) { this.secondsCounter++; this.timer-=1000; if(this.secondsCounter == 60) { this.secondsCounter-=60; this.minutesCounter++; } }  
  23. Like
    3ddy reacted to fillmoreb in "3D" room using only 2D   
    I'm reminded of the game Myst.  The game was built with pre-rendered views.  To look around in a room, you would click a button to turn left, and the pre-rendered view of the wall to your left would be loaded onto the screen.  They are basically using the method you described.  Check it out here:
    https://www.youtube.com/watch?v=e-8CFun3nEw
    The turning animation can be seen at about 3:40 into the video.
    To achieve this, I personally wouldn't try to move the camera, I would just move the background images past the camera to create the illusion of camera movement.  Just keep track of which wall you're looking at, and place the image of the next wall to the right side of the screen (if you were turning to the right), and tween it to the left along with your current wall.  Once the tween is done, you'll be looking at the new wall.
    You can develop the idea further to be able to turn only partway between walls as well, being able to look in any direction, not just the cardinal directions.
    That kind of effect can be seen here:
    http://www.easypano.com/topics/html5-panorama-player.html
    I would still program it in basically the same way as the first example, though.
  24. Like
    3ddy reacted to Gob0 in dynamic android/ios game updates   
    Hi 
     
    you can download data from a website and store it on the phone. Then in your game, you'll have to implement a "fall back" during phaser loading to load the default asset or the last downloaded. 
    I don't have links right now but if i find one, you'll get it 
     
  25. Like
    3ddy reacted to mattstyles in Switching states with preserving objects   
    In your 'constructors' you're appending properties to the `MyGame` object but you're setting them to `undefined`, there is no need to re-declare them in state constructors, if they are declared ONCE in your initialisation code they'll be available from `MyGame` in each state.
     
    MyGame is simply a namespace, conceptually its exactly the same as having them global, with the only real difference being that you (and Phaser) are arbiters of the MyGame object, which you are not of Window.
     
    Theres also nothing wrong with creating a new global, `myState` fro example, that holds state away from the `myGame` object. Yeah, it creates a new global but without a module system you'll just end up using MyGame as a dumping ground as you are now.
     
    But either way is fine, just stop redeclaring (effectively clearing) your variables and you'll be good to go!