I have 6 sprites on screen, now after particular time, I want to reload that 6 sprites without affecting screen. (with removing old & add new images)
like objects are changing in one frame.
I use Layers for this, but I am not able to assign two same sprite in both layers.
How can I switch multiple layer with same sprite?
got the answer.
just detach current layer.
initialize next layer.
overwrite ArrayList (in my case, i have taken arraylist of sprite) of sprite with required images.
attach that arraylist to newly created layer & then attach that layer to scene.
Related
Showing the general setup of the scene and where the sprite is
the sprite is "behind" the background but the Z-value should be correct
I have tried solutions such as changing the render mode of the canvas; the different options do not work and "World Space" turns the game view into the default background color. I could not figure this out after a day of reading up manuals/guides and looking at other questions. Thank you for helping me!
The issue is you are trying to use a SpriteRenderer on a Canvas object. Remove the SpriteRenderer and either use an Image or RawImage component instead.
Another note regarding UI that you will inevitably run into is unless specified otherwise, objects further down in a Canvas hierarchy will render on top of those above it.
I would also avoid changing the z-axis on all of your objects. Make Canvas groups that have different sorting layers to render groups on top of one another. Place objects in a specific order in the hierarchy to get the draw order you desire. Messing with the z-axis in a 2D scene can be a headache down the line and is not very modular. If you want to change sort order later, the specific z offset you set to each object will need to change.
I have two sprites I downloaded off the asset store on my canvas one is a building, one is the foundation the building sits on.
However, in my game these two sprites will always be together. I'm going to be creating many instances of these on my map and I don't want to have to drag each piece on to the map individually and position them. So I was hoping to highlight them both and turn them into a prefab so Id just have to manage one object instead of dragging around both sprites.
I could just open them in photoshop and combine the two images but I'd prefer to just put them together in unity and leave my sprites modular.
You can create a empty object. This object is parent object.
Then in hierarchy window, you drag 2 sprite to this parent object. So 2 sprites is child of parent object. Make this parent object as prefab.
I'm creating a 2d game using Unity and get the following problem. When I change the layer of some game object in its reference prefab, I can not see that game object in the scene window.
In Unity, cameras can view one or more layers simultaneously. If you have created a new layer, be sure that at least one of your cameras is set to render it. You may have placed your object on a layer which is not currently being rendered on any of your scene's cameras.
Maybe you have set some layers as invisible. You can check visible layers in a popup list "Layers" at top right corner of Unity Editor window.
I try to create my own tile map dynamically such as some buildings created with the help of database. I try to use CCSprite on object layers. However, when i scroll the map, also CCSprites' move too. I don't want to move all of the Sprites whenever player scrolls the map. (For performance issues)
Then, I decided to create my own CCTMXLayer over the background layer. How can i create my own CCTMXLayer dynamically?
You can modify an existing tilemap using CCTMXLayer's setTileGID method, so create a tileMap in Tiled (or whatever editor you choose) with a single tile.
Then once you have loaded the map into a CCTMXLayer use the setTileGID to change what the tiles are.
Alternatively you could create a new CCLayer and then just add a sprite for every tile in the game, however, you should probably user a textureAtlas or a batchNode if you decide to take that approach. Then to move the map you just change the position of that layer.
I am learning cocos2d and that we have multiple layers in single scene.
I want to manage both layers at a time I.e, first scene with 480X320 image and second one also with same size. when I try the second one is only visible. Thats ok. But whenever touch occurs I want to add another sprite to both of the layers (different sprites for each). Could any one help with this.
Thanks
Why are you using multiple layers? Layers are for grouping multiple objects so that you can apply effects like movement to all nodes of the layer.
It sounds to me as if you should just be adding sprites to one layer. And if you add two sprites at fullscreen size, one will be on top of the other regardless unless it has transparent parts in the image.