iagnkankadlg Posted July 24, 2018 Share Posted July 24, 2018 Firstly, I am quite new to making games. I do have decent JavaScript knowledge though. What I want is to attach a specific part of the arm sprite, onto a specific location of the body sprite. But, I have already created a 2 independent systems for the 2 sprites: 1. Arm Sprite Angle works! var arm; var player; function create () { arm = this.add.sprite(player.x, player.y, 'arm').setOrigin(0, 0.5); } function update () { if (cursors.up.isDown) { arm.angle += -0.5; } if (cursors.down.isDown) { arm.angle += 0.5; } } 2. Body Sprite Movement Works! function create () { player = this.physics.add.sprite(400, 315, 'dude'); } //player is body I am not going to bother pasting the code for the player movement because it is quite long. Basically, it is controlled by setting velocity. It can move up and down & left and right. The above code works fine, what I want to do is set the location of the arm to always be in the appropriate spot on the body, even when the body is moving. Then I also want the arm to be able to move up and down as in the code above (point 1.) When I was first doing research on a solution, I found that Phaser 3 doesn't have a parent / child system for attaching things. Instead it has a container system. I'm not entirely sure how containers work. Can I make the body into a container, and then have the body able to be affected by the world and also able to move around, and then also have the arm rotate independently from the rotation of the container? Another Question, how do you guys learn Phaser 3? I am struggling to find documentation. Currently I am looking at examples at https://labs.phaser.io/ and then trying to apply them to my own work. Link to comment Share on other sites More sharing options...
samme Posted July 24, 2018 Share Posted July 24, 2018 https://phaser.io/phaser3/devlog/120 https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Container.html Link to comment Share on other sites More sharing options...
Recommended Posts