-
Posts
42 -
Joined
-
Last visited
-
Days Won
1
brejep last won the day on November 17 2014
brejep had the most liked content!
Profile Information
-
Gender
Male
Contact Methods
-
Twitter
brejep
Recent Profile Visitors
1,903 profile views
brejep's Achievements
-
brentstrandy reacted to a post in a topic: Loading Images
-
I would load the image once with a single key. This is the key associated with the image in the cache and I think it would unnecessarily complicate things to have several references to the same image in the cache. My suggestion to solve your problem would be to map these strings to a cache key. This could be done fairly easily with an object: this.load.image('red blood splatter', 'images/red splatter.png'); this.load.image('green blood splatter', 'images/green splatter.png'); var cacheKeyMap = { 'alien x blood': 'red blood splatter', 'alien y blood': 'red blood splatter', 'alien z blood': 'green blood splatter' }; Then you just need to look up the mapping to get your cache key: this.game.add.sprite(x, y, cacheKeyMap['alien ' + alienType + ' blood']);
-
Batzi reacted to a post in a topic: Adding sprites
-
The relevant bit of the docs is: http://phaser.io/docs/2.4.4/Phaser.GameObjectFactory.html#sprite. game.add.sprite(0, 0, 'wallH', 0, this.walls); is getting a texture from a spritesheet, so 'wallH' is the key for the spritesheet and the 4th argument (0) is the frame of that spritesheet. The last argument is telling Phaser to add this sprite directly to a group (this.walls) rather than at the top level or into the world group.
-
Your designers could still use Flash if that is a tool they are comfortable with. There are several options to export from Flash for use with HTML5 projects: You could use Flash CC's in-built publish to HTML5 canvas option. It outputs for createjs.You could use Photonstorm's Flash to Phaser jsfl script - http://www.photonstorm.com/phaser/flash-to-phaser-jsfl-script. If you need something more customised, your developers could always write a custom jsfl command to export scene information as json. There are already lots of examples on github.
-
I would filter the array using a point-triangle collision detection, e.g. http://codepen.io/anon/pen/EVJKNQ inTriangle = _.filter(mappedArr, function(cell) { return pointInTriangle(triangle, cell); });For this example, I've flattened the 2D array into a 1D array with x and y values stored in the array, as that means I can use a filter function more easily. For point-triangle detection, I've used this simple check: function side(t0, t1, pt) { return (t1.y - t0.y) * (pt.x - t0.x) + (-t1.x + t0.x) * (pt.y - t0.y); }function pointInTriangle(t, pt) { var checkSide1 = side(t[0], t[1], pt) >= 0; var checkSide2 = side(t[1], t[2], pt) >= 0; var checkSide3 = side(t[2], t[0], pt) >= 0; return checkSide1 && checkSide2 && checkSide3;}Also, I've used lodash in the example - I use it quite a lot and I like the syntax - but there is nothing I've used it for you couldn't do easily without.
-
Sounds like an interesting problem but I'm a little unclear about what you are asking. Are you already able to get the objects you have highlighted in blue in your diagram? Are you trying to get the objects that are fully inside the triangle and that, therefore, don't bisect the lines that form the triangle?
-
Zoja reacted to a post in a topic: Where to start - Python - JS - Engine: Blender? Librarys?
-
Where to start - Python - JS - Engine: Blender? Librarys?
brejep replied to Zoja's topic in General Talk
Phaser is a very good choice for 2D game development. It is open source, so is free to use and has a really helpful and very active community, particularly, on these forums. The examples are a good place to start. It currently uses Pixi.js for rendering but adds a lot of game specific code to help you in creating 2D games. For getting a game up and running really quickly I've not found anything better. -
You could use a rectangle: this.game.input.onDown.add(function(pointer) { if(Phaser.Rectangle.containsPoint(hitAreaRectangle, pointer.position)) { // do something }});The event is on game.input but you could use your rectangle geometry to hit test the pointer and then execute whatever behaviour is meant to happen.
-
Steering behaviours would be one approach. There is a quite good series of introductory tutorials on steering behaviours here: http://gamedevelopment.tutsplus.com/series/understanding-steering-behaviors--gamedev-12732 The code examples would translate to Phaser reasonably easily.
-
If you cache the sprite as a bitmap - cacheAsBitmap=true - it should stop that unwanted effect of uneven fades.
-
drhayes reacted to a post in a topic: States as Objects or Functions
-
ZoomBox reacted to a post in a topic: States as Objects or Functions
-
Both work, so it is mostly a matter of personal preference. I've used functions for states in the past because I've used the new operator and tried to keep a sort of OOP/classes style to my code. As everything else has used function and prototype, I didn't want to code states in a different way. Also, Phaser itself uses function/prototype for classes so following that style makes sense if your game relies on Phaser as a framework. Objects are a little bit lighter weight but if you are just creating one instance of them that won't have much of an effect on performance. I am, personally, trying to move all my code into a more object-based model - i.e. not using the new operator but Object.create instead. It is JavaScript so there are lots of ways of doing everything, most of which have good and bad aspects.
-
Hi, This sounds like a very interesting project. I'm a freelance developer and I was wondering if you work with developers remotely or would they have to be based in Frankfurt? Regards, Brett
-
HTML5 Developers Wanted for Assembly Product
brejep replied to thebigpumpkin's topic in Jobs (Hiring and Freelance)
Oops, hadn't really grasped how this Assembly things works. -
HTML5 Developers Wanted for Assembly Product
brejep replied to thebigpumpkin's topic in Jobs (Hiring and Freelance)
Hi, I was wondering if you could provide a bit more information about what developer roles you are hiring for - length of project, size of team, remote or on site working, who to contact, etc. Cheers, Brett -
lewster32 reacted to a post in a topic: Code structure and efficiency: Tips and Tricks
-
hellspawn_bg reacted to a post in a topic: Code structure and efficiency: Tips and Tricks
-
Both PIXI and Phaser and a lot of other libraries use the prototypal inheritance pattern you have described, so you can't get away from it entirely. The statement is rather broad, see for example, the top answer here: http://stackoverflow.com/questions/3493252/javascript-prototype-operator-performance-saves-memory-but-is-it-faster which suggests prototype can be faster than other options. Prototype will also often save memory, another important factor on phones. I think an important thing to note here is the rule of premature optimization. I see a lot of developers worrying about performance far too early at the expense of readable and maintainable code. If you are struggling with performance on phones, I'd do some performance tests and see which bits of your code are struggling. Chrome dev tools or similar can help here. Start by looking at looped code that is doing a lot of work - calling functions and changing a lot of properties and see if this can be optimized. Also, as rendering is often a bottleneck, I'd look at graphics, any way they can be reduced in size? I suggest pngquant and a good build tool (like gulp or grunt) to create optimized assets every time you build. If you do want to move away from prototype, one option you can think about is Object.create(null); As that will create an object without a prototype. So similar code to yours above would be: function myMethod1() { console.log('myMethod1');}function myMethod2() { console.log('myMethod2');}var klass = Object.create(null);klass.myMethod1 = myMethod1;klass.myMethod2 = myMethod2;// clone the objectvar instance1 = Object.create(klass);var instance2 = Object.create(klass); Be mindful that these objects will not have functions like hasOwnProperty or isPrototypeOf and may have properties that don't show up in console.log or console.dir as well.
-
hellspawn_bg reacted to a post in a topic: Phaser Frame Rate
-
By default, Phaser is using requestAnimationFrame, see here for an explanation - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/. It essentially keeps the timing inline with the refresh rate of the display (normally 60fps). To update more often, it looks like you could force Phaser to use timeout instead by sending the game a config option of forceSetTimeOut = true and then you could set game.time.timeToCall to a number of milliseconds less than 1000/60. Depending on what you are updating, you could always do it with a separate timer outside the main game loop.