adamyall

Members
  • Content Count

    56
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by adamyall

  1. New blog is up: More AMD Modularization and Finite State Machines in Phaser - Cleared up some issues with AMD modules from the last blog. Used the TypeState library to show how to easily use Finite State Machines in Phaser! Has example code and a demo! Shows how to use Finite State Machines for cleaner, extendable, and reusable code for Phaser in TypeScript. Demo
  2. Hey guys, Over the past few weeks I have been learning more about Phaser and TypeScript and I have started a blog to share what I have learned and post code that I think will help people better use Phaser with TypeScript. I was waiting to post anything about them here until I had a post with actual code in it and a GitHub repo. (Though I saw today a link to one of the posts was on the front page, thanks Rich!) I use OSX and WebStorm, but you should be able to use the code and examples in pretty much any TypeScript environment. But keep in mind these tutorials use more advanced TypeScript features (AMD modularization etc). Posts: Set Phasers to TypeScript! - Setting up a TypeScript dev environment the hard way (Brackets, Prepros, Terminal), or the easy way (WebStorm) Big Boy TypeScript: AMD Modularization and Dependency Management – Part 1 - A preface to using AMD modularization, with some "guided reading" to explain the concepts. Big Boy TypeScript: AMD Modularization and Dependency Management – Part 2 - Has example code from a Git repo. Shows how to organize your project to use AMD Modularization. Introduces you to the three ways you have to import and reference files as well as how to export classes and modules. More AMD Modularization and Finite State Machines in Phaser - Cleared up some issues with AMD modules from the last blog. Used the TypeState library to show how to easily use Finite State Machines in Phaser! Has example code and a demo! More to come! If you haven't ever used TypeScript, I would recommend doing some reading at the TypeScript website before reading these blogs. Afterwards, do some Phaser stuff with TypeScript.
  3. adamyall

    mummy exmple

    You can flip a sprite horizontally by setting it's x scale to be negative. For instance, change this: mummy.scale.setTo(2, 2); To: mummy.scale.setTo(-2,2);
  4. ".call" is used in JavaScript to call a function with a different scope than the scope in which it is called. In other words, Phaser.Sprite.call(this,game,x,y,v[0]) is equivalent to Phaser.Sprite(game,x,y,v[0]).
  5. Similar question:http://www.html5gamedevs.com/topic/5351-call-a-function-with-arguments-when-oninputdown/
  6. Glad I was able to steer you in the right direction! I'm really liking typescript with Phaser, it forces you to write cleaner code. I'm glad that Phaser is so versatile, but I'd like to see more people using TypeScript, because seeing the completion and inheritances will clarify the structure of Phaser immensely. So kudos for going that route. Btw, my next few blog posts at adam-holden.com are going to be related to TypeScript with Phaser. /self promotion
  7. It's hard to tell without seeing your whole file, but if that jump function is in the class definition, try removing the "function" keyword. What I think is happening is that you are making that jump function a member variable of the type function (In JavaScript Syntax, not TypeScript syntax btw). Therefore when you call the function, "this" is referring to the function itself, not to the class that you have added it to.
  8. http://jsfiddle.net/adamholdenyall/G68ee/7/ Made a fiddle to figure this out myself. Probably the best way to handle gestures is to just include Hammer.js as gesture support in Phaser itself is limited as far as I can tell. The example shows both pinch to zoom and scroll to zoom. Works for me on Chrome for Android and Firefox.
  9. You're welcome, I hope more people see it.
  10. Pull request added. (Here's a link for anyone interested) https://github.com/photonstorm/phaser/pull/706
  11. Have you tried setting the outOfBoundsKill flag on the sprite to true? I think that will do it for you.
  12. I figured out how to do it, but you have to touch a lot of private members. I'm going to take a crack at implementing it in 2.0.3 dev, but not going to make it a parameter to play.
  13. Something like that is definitely a fallback
  14. I have a jump animation and a midair movement animation. The jump animation is 5 frames long, and I want it to play all the way through when the player jumps from a grounded state. However if the user jumps starting from the ground, then starts to move left or right, it plays the midair movement animation. Now, when the user stops moving, I want to transition back to jumping, but starting at frame 4 or 5 of the jumping animation. sprite.play(name);sprite.animations.frameName = frameId;I've also tried using animations.frame = number, but no luck with that either. I just need to know if there's a play, but skip to frame method that I'm not seeing.
  15. Are you hosting these files on your machine? Or just trying to open a file from your drive? In other words, does the URL start with http or file?
  16. You'll need to read up on how git works, and make an account on GitHub. Then you can fork the Examples repository: https://github.com/photonstorm/phaser-examples, add your new examples, and make a pull request for your examples to be re-integrated into the master branch of the repository.
  17. http://www.html5gamedevs.com/topic/5390-best-way-to-build-a-rope-with-p2/#entry33146 I'd imagine a solution would be similar to this, though eventually you would want more joint constraints.
  18. http://www.html5gamedevs.com/topic/5390-best-way-to-build-a-rope-with-p2/#entry33146 I'd imagine a solution would be similar to this, though eventually you would want more joint constraints.
  19. Doesn't silk do cloud based rendering or something (somewhat like opera mini)? That could be the reason it's saying Linux even on a tablet. Regardless, I guess it's fixed now.
  20. Note that your code will have to be more clever and use less hard-coded values if you go the route mentioned by Videlais. By all means it's the best, most flexible approach, but you will have to make your code more flexible, instead of just using iPhone screen sizes.
  21. In a massive JavaScript project, you don't want to have a 100,000 line text file open at all times. You also would not be able to do Source Control as easily if every change was basically a merge. Another aspect would be not being able to mix JavaScript, CoffeeScript, and TypeScript (Don't know if this is ever really done though). Updating a library dependency would mean copy-pasting the parts you need into your file or forcing the user to include that library as well. Technically, you could write your game in a development environment where you have included all the src, and it would be the same as using Phaser.js or phaser.min.js. However, that would be awful for the user. build/phaser.js and phaser.min.js are the JavaScript equivalent of a C++ dll file. Lots of code merged together and placed in one file so that it's easier to include, and is also sufficiently black-boxed (especially in the case of .min.js) so that you rely on the documentation and aren't tempted to modify the source of Phaser (and if you do, you're more likely to pull down the repo of Phaser and share your fixes/improvements) So yeah, with all JavaScript libraries, you want to get the main files under build, like phaser.js and phaser.min.js. When you are in development mode, it's best to use the non-minified version as you can debug through it and get better errors. When you go to deploy, switch to the min versions.
  22. I opened it up on my Android phone and it seems to be broken similarly. I am getting: "Cannot read property 'x' of undefined" joystick.js:215 "BasicGame is not defined " ~Boot.js: 75 and 83 Maybe that will help point you in the right direction.
  23. I tried taking a look at the template code, but I wasn't familiar with how the docs are built. I ended up making a UserScript that can act as a band-aid for this problem until the doc generation is updated: http://userscripts.org/scripts/show/453098 This simply uses jQuery to indent based on some of the namespace structure. More of a hack than a fix, but I prefer it now. EDIT: You can install a UserScript after adding the GreaseMonkey extension to Firefox or TamperMonkey with Chrome. Only tested with Firefox.
  24. bmceldowney's solution is probably more simple than mine, but there is another solution in case you don't want to create a new object. This solution uses a feature of JavaScript called a "closure". Basically, whenever you use Signal.add (like with onInputDown.add) you will pass a function that takes no parameters: onInputDown.add(myNoArgumentFunction); But this is only good if the function you want it to call doesn't need arguments. So you might be tempted to wrap your function WITH arguments in a function WITHOUT arguments, which would leave you a function like this: onInputDown.add(function(){myArgumentFunction(someVar)}); The problem with that is that you aren't actually creating a new function, so if you set up input on a loop of 3 items, you may always use the last value assigned to the variable. In my example you actually pass into add() the result of a function that generates a no argument function. You can see the pitfall on the first row, and the working solution on the second row. Here is a fiddle containing my solution: http://jsfiddle.net/adamholdenyall/wk6T3/1/ Like it said, it may be overkill and the other solution may be a better fit, but closures are important to JavaScript and a good tool to have available. Further reading: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Closures