M
mochipon
Guest
I'm using the code almost exactly as it is provided in the examples from the help file, but it won't do anything to the sprites on that layer.
My code:
Obviously, the layer where the sprite assets are on is named Assets_FG_0_2 in the IDE, and the sprite which I'm trying to move is named "spr_block_attach" without the quotes. It's currently the only sprite with that name on that layer (I keep wondering what would happen if there were more than one; which id would layer_sprite_get_id return!?)
I tried substituting the "asset_x" in the last line with a number, but that wouldn't move anything either. The sprite itself remains exactly where I placed it in the IDEs room editor.
What am I missing/misunderstanding here?
Edit:
I'll elaborate a little, and explain what I'm trying to achieve.
I'm creating a parallax scrolling effect, where the foreground scrolls faster to give the impression that the objects are closer to the POV. To that end I'm using "layer_x("Assets_FG_0_2",x*-0.2);" to make the layer scroll faster, which DOES work.
However, with a room/level of a certain size, I need to take the faster scrolling of the foreground into consideration when placing assets within the IDE. That is, when I want a certain foreground asset to be in a certain place, when the player is in a certain spot. So my idea was to place the assets in the IDE where I want them to be when the player is at that exact spot, and spread them out into the x and y direction by code in a way that will anticipate and negate the faster scrolling of the foreground layer.
Of course, my experiments got stuck when I couldn't get the "layer_sprite_x" command to do anything...
My code:
Code:
var lay_id = layer_get_id("Assets_FG_0_2");
var spr_id = layer_sprite_get_id(lay_id, "spr_block_attach");
var asset_x = layer_sprite_get_x(spr_id);
layer_sprite_x(spr_id, asset_x*1.3);
I tried substituting the "asset_x" in the last line with a number, but that wouldn't move anything either. The sprite itself remains exactly where I placed it in the IDEs room editor.
What am I missing/misunderstanding here?
Edit:
I'll elaborate a little, and explain what I'm trying to achieve.
I'm creating a parallax scrolling effect, where the foreground scrolls faster to give the impression that the objects are closer to the POV. To that end I'm using "layer_x("Assets_FG_0_2",x*-0.2);" to make the layer scroll faster, which DOES work.
However, with a room/level of a certain size, I need to take the faster scrolling of the foreground into consideration when placing assets within the IDE. That is, when I want a certain foreground asset to be in a certain place, when the player is in a certain spot. So my idea was to place the assets in the IDE where I want them to be when the player is at that exact spot, and spread them out into the x and y direction by code in a way that will anticipate and negate the faster scrolling of the foreground layer.
Of course, my experiments got stuck when I couldn't get the "layer_sprite_x" command to do anything...
Last edited by a moderator: