Jump to content

Search the Community

Showing results for tags 'component'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 9 results

  1. Hi, Phaser devs! I'm developing a game using Phaser with TypeScript and what I'm trying to achieve is this: var component:AwesomeComponent = actor.getComponent<AwesomeComponent>(); I know there's a workaround by constructing objects of type T. But I don't like it because I'd probably need to define tons of different constructors to represent all differents kinds of components. What I'm doing so far is passing a string with the type (of course a number would be better, but I'm still prototyping): getComponent<T>(componentType:string): T { for (let i = 0; i < this.components.length; i++) { if (componentType == this.components[i].componentType) { return <T><any>this.components[i]; } } return undefined; } It works, but the result is not good, you have to type the class name twice: var animComp = actor.getComponent<AnimationComponent>("AnimationComponent"); Any suggestions on how to solve it? I know there`s a way to do it, because Unity does exactly that in JavaScript. Thank you for your time!
  2. Hello! At the beginning of the year, I have a plugin to manage behaviors (based on construct 2) in Phaser games. Now I'm creating some behaviors. Please feel free to help me with testing or feedback. The plugin: https://github.com/luizbills/phaser-behavior-plugin (How to install and use on README) Some behaviors: https://github.com/luizbills/phaser-behaviors (see the Pull Requests too) Check out demo game using "bevahiors": https://github.com/luizbills/phaser-platform-game (see the file game.js)
  3. Is there any Demo or Example how should Brake code on component (from blender Group or Parent Children). So that each component is seperatet .ts or .js and so that each component have its own methods and propertis? greetings ian
  4. Hi! I'm new to JS gamedev, but I had a good experience in Flash/AS3. So, I'm starting a board game, and I need to roll a dice/roulette every turn. A kind of window will appear over the board and the player will be prompted to click the roulette. It will return a value between 1~9. What I have until now is ths: https://jsfiddle.net/snake/m317ona9/ As you can see in my code, I'm using create() and update() methods just to create this example. In real game it wouldn't be handled like that, but in middle of game. I have not so much ideas on how I can make a nice architecture in my code.What I have in mind, with my current small knowledge in Phaser, is to make a lot of conditions to manage states in game loop. The final code would be a maze! The perfect case for me: Create a function which would treat this roulette as a component or something like it, maybe with his own create and update methods, and returning a value to the game, so I can reuse it without the need to mess up my code. Hope I've made myself clear How can I proceed with it? Thanks in advance!
  5. Hello all, I just released my PhaseSlider UI component, which is a (duh!) Slider with many options and functionalities, take a look at the github repo: https://github.com/netgfx/PhaseSlider or the examples here for advanced: http://www.netgfx.com/trunk/games/libs/phaseslider/examples/example1.html or here for basic example: http://www.netgfx.com/trunk/games/libs/phaseslider/examples/index.html
  6. Hi everyone, A few weeks ago Ezelia started a thread about ECS and HTML5 games. As a big fan of this pattern, I decided to build and release my own engine. It is called makr.js and is available on Github (https://github.com/ooflorent/makrjs) under MIT license. A basic sample is available into examples/. The library must be build using grunt in order to test the sample. Any feedback would be appreciated! Update (2015-01-06): Version 2 is under active development (more information) Feedback is welcome!
  7. Hi everybody! Let me start off by saying that I'm pretty new to Phaser – I've been playing around with it for a bit but never made a game with it... so I'm not super-familiar with it yet. However, I have made games using CraftyJS and while that engine pales in almost all aspects when compared to Phaser, I really loved its entity component architecture. Not having to create complicated inheritance tress to share functionality among game objects that are otherwise quite diverse makes so much sense to me. Here's what I've done to add similar functionality to my Phaser project, without touching the Phaser source. I want to get your guys' opinions on it. Also, I'm not completely familiar with the terminology so I'm not sure if these things I'm adding to game objects are mixins, components, traits or something else. 1. Create GameObject constructor function GameObject will be the constructor function that every visible object in the game will use/extend. GameObject extends Phaser.Sprite and adds some methods for managing components on a game object, for example: GameObject.prototype.addComponentGameObject.prototype.removeComponentGameObject.prototype.hasComponentGameObject.prototype.requireComponent // ensures that the game object has a particular component, otherwise throws an errorCurrently, GameObject provides an update method that goes through all registered components on the instance and calls their update-methods if they are provided: GameObject.prototype.update = function() { for (var componentName in this.components) { var component = this.components[componentName]; if (typeof component.update === 'function') { component.update(); } }};2. Create a component Here's a simple movement component that requires another component called "speed" to exist on the game object (entity). var movement = autoCurry(function(entity) { this.requiresComponent('speed'); var speed = entity.speed; var cursors = entity.game.input.keyboard.createCursorKeys(); return { name: 'movement', update: function() { // prepare var velocity = entity.body.velocity; // movement velocity.setTo(0, 0); if (cursors.left.isDown) { velocity.x = -speed; } if (cursors.up.isDown) { velocity.y = -speed; } if (cursors.down.isDown) { velocity.y = speed; } if (cursors.right.isDown) { velocity.x = speed; } } };});I'm using autoCurry to make the syntax a bit more appealing. 3. Add component to a game object var Player = function(game, x, y) { GameObject.call(this, game, x, y, 'player'); this.addComponents(speed(150), movement()); game.physics.enable(this, Phaser.Physics.ARCADE);};util.inherits(Player, GameObject);What do you guys think of this approach? Obviously there are alternative ways to provide components. You might want to have components be constructor functions or plain objects instead of curried functions returning an object – I think that part is probably preference. I'm interested in the viability of using such a system with Phaser particularly. I'm looking forward to a constructive discussion, thanks for posting your thoughts! Best, Max
  8. This isn't necessarily a Phaser- specific question, but I'm just curious about the patterns that are being leveraged in the Phaser community.. In my current project, I'm following the simple and common structure that can be seen in things like XNA. That is, I have my entities acting as wrappers for the phaser sprite something like this: entities/foo.js FooEntityFactory = function(someInitParams) { //some initialization code return { sprite: game.add.sprite(10, 20, 'sprite1'); update: function(game) { //some update code } };};And then I can keep my states relatively tidy by not cluttering it with entity logic and leaving more room for state-specific logic: states/bar.js BarState = { entities: [], create: function() { this.entities.push(FooEntityFactory()); }, update: function(game) { this.entities.forEach(function(entity) { entity.update(game); }; }};However, I'm trying to get some ideas on out how to augment things with an Entity-Component-System pattern. Has anyone else organized their code in such a way that that utilizes this pattern? How about EC?
  9. I've been into PlayCraft Labs game engine and found it quite nice. It utilize an Entity-Component-System framework with several components and systems ready to use by the author, such as particles, physics, effects, etc. Check it out here. To get access to the codes and documentation, you'll need to sign up.
×
×
  • Create New...