weratius Posted October 26, 2015 Author Share Posted October 26, 2015 can you do a jsfiddle?I'm sorry, but I can't do that, there is too much code But I can show what I see Planet is moving And now it's going through There is the planet, the mask and the shadow in the group. And here I'm moving only planetAnd shadow stands still with mask Thank you Link to comment Share on other sites More sharing options...
jmp909 Posted October 26, 2015 Share Posted October 26, 2015 refer to my explanation above and make sure you are masking and grouping the objects correctly first can you at leaste pastebin the code that calls initPlanet(), the initPlanet function and the code that moves the planets so i can see it all in one place (not here) without a jsfiddle it's hard to determine the issue you are better breaking down those functions into manageable chunks so they can be setup as a jsfiddle independently easily. also are you scrolling the texture on the planet? chongdashu 1 Link to comment Share on other sites More sharing options...
weratius Posted October 26, 2015 Author Share Posted October 26, 2015 refer to my explanation above and make sure you are masking and grouping the objects correctly first can you at leaste pastebin the code that calls initPlanet(), the initPlanet function and the code that moves the planets so i can see it all in one place (not here) without a jsfiddle it's hard to determine the issue you are better breaking down those functions into manageable chunks so they can be setup as a jsfiddle independently easily. Ok, I'll make a jsfiddle They are broken down, but it's hard to show a picture of moving planets, because I get the info object from the server, but whether the animation method and planet initialization one is enough,.. so give me 5 seconds) Link to comment Share on other sites More sharing options...
jmp909 Posted October 26, 2015 Share Posted October 26, 2015 yes just the basics. i think you're messing you're mask up somehow. the easiest way to deal with mask is to remove someObject.mask.mask and see where it is being drawn to check it's in the right place Link to comment Share on other sites More sharing options...
weratius Posted October 26, 2015 Author Share Posted October 26, 2015 refer to my explanation above and make sure you are masking and grouping the objects correctly first can you at leaste pastebin the code that calls initPlanet(), the initPlanet function and the code that moves the planets so i can see it all in one place (not here) without a jsfiddle it's hard to determine the issue you are better breaking down those functions into manageable chunks so they can be setup as a jsfiddle independently easily. also are you scrolling the texture on the planet? @Jmp909, here it is P.S. sorry, whole file is wrapped via Browserify so...http://jsfiddle.net/Costa595/Lzwce8hx/ chongdashu 1 Link to comment Share on other sites More sharing options...
jmp909 Posted October 26, 2015 Share Posted October 26, 2015 sorry i meant a working version! never mind... hang on.. hard to tell without working code as I can't experiment with it. this is a problem though i'm sure somePlanet.mask = mask; this.layers.ourPlanets[num].mask = mask;also you're blanking your array every time you make a new planetthis.layers.ourPlanets = []; // <= this clears the arraythis.layers.ourPlanets[num] = game.add.group(); // <= therefore there will only ever be one planet in the array, as all others are deletedfinally ... you return the sprite from your function, not a group containing the planet, mask and the shadow. so when you move the planet the mask and the shadow stay still createdPlanets[planet].planet.x = rotatedX;now i see you originally were moving the shadow and mask separately (now commented out) but your other errors above probably broke that do something like this..this.layers = { backgroundLayer: this.add.group(), behindTheShipLayer: this.add.group(), otherShipsLayer: this.add.group(), playerLayer: this.add.group() ourPlanets: []};initPlanet: function(......) { var thisPlanetContainer = game.add.group(); ... ... var somePlanet = game.add.sprite(x, y, earthBMD); thisPlanetContainer.add(somePlanet) thisPlanetContainer.add(shadow) thisPlanetContainer.add(mask) somePlanet.mask = mask somePlanet.container = this.planetContainer // a reference to the group but see below.. can probably just use .parent() later // later use createdPlanets[planet].planet.planetContainer.x = rotatedX; to move the whole group // although i think you can remove this planetContainer and just use planet.parent() to get the group that contains it // you should really do this in your creation loop rather than inside initPlanet // your planet object should not need to know what this.layers.ourPlanets is. this.layers.ourPlanets[num] = somePlanet // add this planet to the array of planets.... return somePlanet; // personally i would return planetContainer though to just treat the whole returned group as one object rather than worry about container/parent etc.} Link to comment Share on other sites More sharing options...
weratius Posted October 26, 2015 Author Share Posted October 26, 2015 sorry i meant a working version! never mind... hang on.. hard to tell without working code as I can't experiment with it. this is a problem though i'm sure somePlanet.mask = mask; this.layers.ourPlanets[num].mask = mask;also you're blanking your array every time you make a new planet this.layers.ourPlanets = []; I've made smth. like that this.layers = { backgroundLayer: this.add.group(), behindTheShipLayer: this.add.group(), ourPlanets: [], otherShipsLayer: this.add.group(), playerLayer: this.add.group() };So, what's wrong with the masks on that lines? P.s. Sorry, it's really hard to show you a working code, I'm really sorry. And thank you for your help) Link to comment Share on other sites More sharing options...
jmp909 Posted October 26, 2015 Share Posted October 26, 2015 you're trying to assign the mask to both the group and the sprite. you can't and it's pointless anyway also personally i prefer this method.. rather than repeating createdPlanets[planetId]= ... but that's just my preference !// create our new planetvar createdPlanet = new Object();createdPlanet.planet = myObject.initPlanet(....);createdPlanet.nickname = ....// assign our planet to the arraycreatedPlanets[planetId] = createdPlanet;actually i'd then separate it into a functionfunction createPlanets() { for(var planet in planets) { var createdPlanet = createPlanet(... some args ... nickname etc...) createdPlanets[planetId] = createdPlanet }}it keeps your code in more managable chunks and therefore easier to separate out for problem identification . "one function per task" you could fake your data for jsfiddle with egdata = [ {id:1, name:'planet1', race:'human'}, {id:2, name:'planet2', race:'martian'}] chongdashu 1 Link to comment Share on other sites More sharing options...
weratius Posted October 27, 2015 Author Share Posted October 27, 2015 you're trying to assign the mask to both the group and the sprite. you can't and it's pointless anyway also personally i prefer this method.. rather than repeating createdPlanets[planetId]= ... but that's just my preference !// create our new planetvar createdPlanet = new Object();createdPlanet.planet = myObject.initPlanet(....);createdPlanet.nickname = ....// assign our planet to the arraycreatedPlanets[planetId] = createdPlanet;actually i'd then separate it into a functionfunction createPlanets() { for(var planet in planets) { var createdPlanet = createPlanet(... some args ... nickname etc...) createdPlanets[planetId] = createdPlanet }}it keeps your code in more managable chunks and therefore easier to separate out for problem identification . "one function per task" you could fake your data for jsfiddle with egdata = [ {id:1, name:'planet1', race:'human'}, {id:2, name:'planet2', race:'martian'}] You know, everything works fine when they stand still, but when I try to move them.... I can't understand that( I can't put that in fiddle, at all(( too much data in that object Couldn't you just tell how you would move sprites with masks and shadows? Thank you! Link to comment Share on other sites More sharing options...
jmp909 Posted October 27, 2015 Share Posted October 27, 2015 if you look above I have explained that I put earth, shadow and mask in its own group.... they all move as one unit i showed this in my original example http://phaser.io/sandbox/kQxhfHbb/play weratius 1 Link to comment Share on other sites More sharing options...
weratius Posted October 27, 2015 Author Share Posted October 27, 2015 if you look above I have explained that I put earth, shadow and mask in its own group.... they all move as one unit i showed this in my original example http://phaser.io/sandbox/kQxhfHbb/playI have seen that. But couldn't you tell me why I can't see anything when I set mask to some objects For example:When I set a mask to the shadow, I can't see the shadow while it movesWhen I set the mask to the planet sprite , I can't see the planet (it's map) at all, and only when it goes through the mask position, I can see that. But the main question is that: I can't see anything when I'm trying to move the group or set the same coords to the mask like others have I'm stupid(( Link to comment Share on other sites More sharing options...
jmp909 Posted October 27, 2015 Share Posted October 27, 2015 look at my example again.. i only move the "planet" group with my mouse. everything else (earth sprite, mask, shadow) is inside the group (hold the mouse button down to see them)http://phaser.io/sandbox/kQxhfHbb/play if i want more than one planet i would create another "allPlanets" group to put my "planet" group in. i do not think you have your group/mask set up properly. did you fix the error in your code where you were assigning the mask twice? it sounds like your mask is staying in one position and you're moving everything else away from it. weratius 1 Link to comment Share on other sites More sharing options...
jmp909 Posted October 27, 2015 Share Posted October 27, 2015 have a look at thishttp://phaser.io/sandbox/UyQWwedw/play note: i return the container group from my function whereas you return the sprite that is in its own container group.. so you may need to refer to .parent to reference the container weratius 1 Link to comment Share on other sites More sharing options...
fazz Posted March 31, 2017 Share Posted March 31, 2017 Apologies for the necropost. I've been adapting your http://phaser.io/sandbox/kQxhfHbb for a project of mine. I wanted to slow the movement of the bitmapData object. In the update function there is the code, earthBMD.move(-1,0); If I adjust that to -0.1 the image blurs. It seems that http://phaser.io/docs/2.6.2/Phaser.BitmapData.html#move only operates correctly with integer values. Can anyone recommend a workaround for this? I can slow the movement by only calling the above code a few times a second, rather than every frame, and although this does slow the movement, it produces quite a noticeable stutter. Thanks in advance! Link to comment Share on other sites More sharing options...
Recommended Posts