• Content Count

  • Joined

  • Last visited

About GreenCloversGuy

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Couldn't see a way to directly modify the texture source, easiest way is to destroy the key/texture pair before generating another texture.
  2. I'm not great with Matterjs, however I believe you want to use constraints to create a Constraint of size 0? I don't know how to use constaints in Phaser 3, but you can see an example in put MatterJS here.
  3. I think we need to see more information to really get a good idea of what's going on here. Can you show us an example when you have multiple tickets? Does it start out with the reduced time when you add more tickets or do you draw a bit first on the mask and then frame rate goes down?
  4. I desperately want a tutorial on shaders, I think that a lighting effect would be good for a scene in my game, and a distortion effect to simulate drunkenness would be good as well. But I have 0 expeience with shaders and I can't tell when a shader is a single 3D object or when it's a filter for a 2D plane! I think some point before the end of the year I'll do a tutorial about how to create a text-based game using Ink and Inkjs, as that's what I'm currently using for my game at the moment. It's pretty powerful and used a lot in Unity games at the moment.
  5. Origin is set on a scale of 0 to 1. If you want to set the origin, you can just use the setOrigin function! gameOverText.setOrigin(0.5) Example here:\game%20objects\text\static\text%20origin.js
  6. I looked at your code, I like it, I've never used Arc before but you've made it look like the effect you're going for! I've updated you Polygon class: var Polygon = new Phaser.Class({ Extends: Phaser.GameObjects.Arc, initialize: function Polygon(scene) { rotationPosibilities = [0,40,90,140, 280], scene, game.config.width / 2, game.config.height / 2, 600, 0, 300) this.setIterations(0.2); this.lineWidth = 40; this.strokeColor = 0xFF0000; this.strokeAlpha = 1; this.isStroked = true; this.setClosePath(false); this.rotation = rotationPosibilities[Math.floor(Math.random() * Math.floor(4))] scene.add.existing(this); } I've put all of the needed arguments into the call function, which meant I was able to remove the setOrigin code as well, because now it is properly set in the centre. I also add scene.add.existing(this) to the end of initialize, which means when you create the object it adds the object to your scene straight away! I had to edit the code near the bottom to make sure it didn't break it: polygons.push(new Polygon(this)); To add the physics to your program, there's a couple of things you could do, but the one I would do would be creating a thin body at the "opening" of the shape and then, if the player doesn't collide with the rectangle during a certain size for the polygon, the polygon sends a "gameover" event.
  7. Honestly, I would use ES6. However if we do it your way, you can save yourself quite a bit of hassle by using the whole of the parent constructor. I think (not sure) that it's common policy to add some code so that your sprite is auto-loaded into the scene when constructed. var CustomObject = new Phaser.Class({ Extends: Phaser.Physics.Arcade.Sprite, initialize: function CustomObject (scene, x, y) {, scene, x, y, 'object'); scene.physics.add.existing(this); } }); I would also use the GameObject version of Sprite rather than the Physics.Arcade version, but I don't actually know the difference between the two!
  8. Looking at the documentation, it seems that Group.create will, by default, create a sprite. You are making a sprite which has, as it's only set value, your Tower object as it's x. You can either use the add method instead: this.towers.add(new Tower ({...}) OR you can set your classType of the group to Tower instead of Sprite, but I'm not sure how this will interact with your config object. Best of luck!
  9. Having played around with it, it looks like you need to set the origin of the line to (0, 0). sprite1.on( 'pointerdown', () => this.add.line( 0, 0, sprite1.x, sprite1.y, sprite2.x, sprite2.y, 0xff0000 ).setOrigin(0, 0) ); The reason for this is because the line is being drawn from it's centre. It's easier to explain with a rectangle. let r2 = this.add.rectangle(sprite1.x, sprite1.y, sprite2.x-sprite.x, sprite2.y-sprite.y, 0x6666ff) (I don't know if this is how Phaser draws shaped, however the outcome is the same, so I'll use it as an example.)This code will draw a rectangle with a width and height that is the difference between the two sprites. It will draw this sprite around the origin, which is set to the centre of the shape by default. So, the shape is drawn around the origin, with the top left corner being in the top left quadrant, with both x and y being negative. When it's moved, we add the cooordinates of spritex and sprite.y to it, causing the lop left corner of the sprite to be to the left and above the moved coordinates. I explained this really badly, I'll try and draw a picture of this later.
  10. Found this plugin for boards recently, includes a hexagon-style board. Hope it helps!
  11. Thanks for the update, however sleep is not the same as pause. I wanted the player to still see the main game when opening the menu, sleeping the scene stops it from rendering. Also when I transition back to the main scene, if I've paused the scene I'm transitioning to, the scene does not resume, it restarts. Not perfect! I managed to create the effect I wanted by creating two additional scenes. class WorldToDiaScene extends Phaser.Scene{ constructor(){ super('WorldToDiaScene') } create(){ this.scene.transition({ target: 'DiaScene', duration: 1000, }) } } class DiaToWorldScene extends Phaser.Scene{ constructor(){ super('DiaToWorldScene') } create(){'transitioncomplete', ()=>{ this.scene.stop('DiaToWorldScene'); }) this.scene.resume('WorldScene'); } } I launch the first scene from my main scene, which transitions into the menu. Then, when my menu is closed, I have it transition to the second scene, which resumes my main scene and, after the transition is completed, stops itself.
  12. Having come back to it after a day, I can see that a transition will do most of what I want. I was treating them more like tweens then as, for lack of a better word, handlers. I still have an issue with being unable to work with paused and resumed scenes, having to force them to sleep instead which isn't perfect. Is it possible to run a transition and have it pause the scene instead? Possibly by having a go-between scene which is launched and which instantly transitions to the scene I want to see?
  13. Hello all, I have a scene in my game, a menu UI scene, which I want to "Dismantle" before it shuts down. Basically, I want the text boxes to fade away and the character art to move out of the screen. I've used tweens to have the items enter the scene when the scene is created, and I've set up the tweens so that they will yo-yo and I've paused them just before they start to yo-yo, so all I need to to is resume the tweens on my gameobjects. My issue is that I need to set up my game so that when a scene should stopped, it instead resumes these tweens, waits for them to finish and then stop the scene. I'm aware that I could do by having any code that closes the scene first emit a "stopscene" event, have my gameobjects listen for this event, resume the tween and then emit an event after they have both finished, however this seems messy and complicated. I've looked into transitions but I don't believe you can use transitions on scenes that have paused or launched and when I tried playing with them earlier, I found myself resetting the scene I was trying to resume. Is there a nice easy way for me to "prepare" a scene for stopping, perhaps through the scene manager or by extending the scene and overriding the code that will stop the scene?
  14. Sorry to revive a sorted issue, but I have to ask, why is the origin of text different to the origin of other game objects? Are there any other game objects with origins other then (0.5, 0.5)? And wouldn't it make sense to make reference to this in the API? I know the API is still being worked on, but I nearly went crazy trying to get my text to align properly because I didn't realise that the origin was (0, 0) and not the default 0.5. Is this an issue I should raise on github?
  15. Should be able to use the onCompleteEvent, using the name 'animationcomplete' and adding an event listenter onto your sprite. Example here: How I would do it:"left", true).on('animationcomplete', () => {"right", true).on('animationcomplete', () => {"turn", true)} )} ) Edit: Whoops, seems more complicated than this, I just tried the code and this code seems to cause an infinite loop for the third animation in the list. I think it's because I used the on on the animation and not on the sprite, which is kind of annoying, if understandable. You'll probably need to create a single 'animationcomplete' listener on the sprite that changes which animation is next based on the animation that's just ended. Example: (animation) => { if (animation.key == "left")"right", true);