Ninjadoodle Posted September 13, 2018 Share Posted September 13, 2018 Hi @enpu I'm making a timer bar using drawRect, and I'm wondering if you can set anchor points? When I put the graphic inside the original canvas size, it tweens as if the anchor was at (0,0), however when I move the graphics slightly outside the canvas, it looks like the anchor is always at (0,0) of the canvas. Thank you for your help! Quote Link to comment Share on other sites More sharing options...
enpu Posted September 13, 2018 Share Posted September 13, 2018 Yes you can set anchor points in Graphics. 1 hour ago, Ninjadoodle said: When I put the graphic inside the original canvas size I'm not sure what you mean by that or what actually is the issue? Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted September 13, 2018 Author Share Posted September 13, 2018 @enpu - it seems that wherever I put the graphic on the stage, it tweens its scale from the ‘stages’ (0, 0) position. This could very well be something I might be doing wrong, I just can’t seem to get it working correctly. Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted September 14, 2018 Author Share Posted September 14, 2018 Hi @enpu Unless I'm doing this wrong there is something up with graphics and tweening. I've setup a bar png and tried tweening its scale and that works perfectly fine. When I try tweening a graphic tho, the tweening / anchors seem all out of whack. This is my graphics setup code. this.bar = new game.Graphics(); this.bar.fillColor = '#ff0000'; this.bar.drawRect(320, 320, 480, 100); this.bar.addTo(game.scene.fg); game.Tween.add(this.bar.scale, { x: 0 }, 20000, { easing: 'Linear.None' }).start(); The bar scales as if it anchor point was set somewhere else but its top left corner . Am I missing something/ doing something wrong here? Thanks again Quote Link to comment Share on other sites More sharing options...
enpu Posted September 14, 2018 Share Posted September 14, 2018 You should draw your rectangle at position 0,0 and then move the whole graphics object to the position 320,320. Position of Graphics object and the position of shape is different thing, shapes have also positions because Graphics object can contain multiple shapes. this.bar.drawRect(0, 0, 480, 100); this.bar.position.set(320, 320); Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted September 15, 2018 Author Share Posted September 15, 2018 Hi @enpu Thanks for this! I've actually encountered this before, and completely forgot, that the graphics had to be created at (0, 0) It works like it should now Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.