How to move animatedsprite reverse when it collides in andengine - sprite

I am moving many AnimatedSprites randomly, but it overlapps with others.
How can i stop that overlapps & make sprite's moving reverse when it collides..?
or should I use another thing which can provide facility for move sprite when it collides...

using body you can solved overlapping problem of sprites.

Related

Prevent modulating color of specific child sprites in godot

Updated: I had a hacky way to fix this in the answers below, but #Theraots answer is the proper way to go about it.
I am creating a game with fish.
In order to modularize my project, I decided to make a base Fish scene and use an instance of it for my FishPlayer and School scenes. This way I can simply use a base Fish in other areas in my game.
In my FishPlayer scene, I would like to add color to my fish which I do by using the modulate property in CanvasItem. However, the only problem with this is that it changes the color of the CPUParticles2D of my base Fish scene. The same thing happens as well in the FishSchool scene.
So, the end goal here is to keep the original particles color of the base Fish scene while in a new scene allowing color modulation of the rest of the base fish.
I've been messing with the shaders of the CPUParticles in hopes that it would prevent the parent instance from changing it but does not work in my case. Any ideas of what I'm missing here?
Here's a fix that I read about, but didn't work in my case: link
From the context menu of the scene tree on the scene where you instance the fish… Select Editable children. Then you will have access to the child nodes of the fish (while it is still an instance of that scene), so you can use modulate only on the nodes you want, instead of having to use modulate on the root of that scene.
The fix I ended up implementing isn't pretty, but the easiest is to grab the individual sprite nodes and modulate them

Can you hide a node when not directly above a parent in Godot?

So I have an instanced scene that is supposed to be the child of a colour rect in my tree. I want to randomly generate the nodes, but I also want parts of the view to be cut off if the texture no longer is above the main section. I know you can render nodes below their parents, but I don't know if stopping part of them from rendering is physically possible.
In this image I want the bottom circle to remain the same, but the top circle to not show anything above the dark purple box
This is the node tree in the editor
Is there any way to do this directly, or am I gonna have to use a viewport of some variety?
I believe what you want is to set rect_clip_content to true on the ColorRect (or whatever Control). Making invisible any part of its children outside of it.
From Godot's documentation:
bool rect_clip_content
Enables whether rendering of CanvasItem based children should be clipped to this control's rectangle. If true, parts of a child which would be visibly outside of this control's rectangle will not be rendered.
If what you want is the opposite, perhaps you can use z_index to have something render on top, occluding the parts you don't want visible.
There is also a trick you can use with lights (including 2D lights):
Make a light that matches the area you want things to be visible.
Set a custom material that will be transparent by default, but visible on the light pass. The simpler way to do this is to set the light_mode of the material to "Light Only". You could also do it with a custom shader instead.
Making something disappear with light, in 2D, is impossible. In 3D, you can use flags_use_shadow_to_opacity. That is how you make a shadow catcher.
But, there is one more trick: you can use a mask. This should give you full control of when to show or hide things. So, if none of the above solutions works for you, use a mask. I have an explanation in a different answer. See also: How to crop sprite in a non-rectangular form?.
Mighty Mochi Games recently (2022-03-30) made a compilation of the different approaches in video form: Mask Methods Collection - Godot 3.x - 2D
.

Phaser - How to access a certain element on the layer

Hello i recently started to study Phaser and i have came to a problem witch i need help with solving.
I created a 3 layer map with Tiled. SkyLayer, GroundLayer, BrickLayer. I added physics that allow the player to move around the GroundLayer. I also added physics that allow him to jump on the BrickLayer. I am struggling to make a motion that allows the player to jump from the bottom hit the brick with his head, when he hits his head the motion of the brick to move up a pixel and then back down a pixel just as in Mario. I have trouble finding out how to identify which brick section i have hit from the BrickLayer so i can later on apply the animation to the brick element.
Simple Layers itself contains only tiles, which has no any animation.
If you need something to have animation, you need to use object layer and convert its objects to sprites with TileMap.createFromObjects.

Anyone know if its possible draw to erase the picture on the top?

Scratch allows selection of the color using the set pen color. Does anyone know if its possible to program to set the color to transparent so that what ever is drawn can effectively be erased? What would the color number be for that?
Update
The idea was to cover a picture (background) with a colour drawn over the top. Now give the player a little creature that erases the colour on top, they have a certain amount of moves or time to guess what the picture is. The less moves/time they use the more points the player will be awarded.
But the problem seems to be that in the paint a sprite part of scratch erase is an option, but not in the pen programming.
If I cant solve it using erase apprach, my alternative is to make a lot of sprites covering the picture and hide them when the creature touches them. But it seems less fun for the player as the uncovered patterns will be more predictable.
Unfortunately, this isn't really possible. If you have a backdrop that's all one color, you could set the pen color to be the same as the backdrop and color over what you already have (giving the illusion of erasing), but other than that there really isn't a good way.
Your only other option is to use the clear block and then re-draw everything except the piece you want to erase.
If you want to give more context about your specific project, I might be able to help you work out a solution (I've done quite a lot with pen blocks over the years).
Like PullJosh said, it isn't really possible but you can make a sprite called Cover and make it a circle of any color you want. Then, it can clone it's sprite over the sprite you want to hide. Then you can attach a script to the clones:
https://i.stack.imgur.com/S6h4c.png (ctrl + click)

Moving elements on a layout controlled programmatically

My goal is to create something like the arrow from car that indicates the speed of the car. My problem is that I do not know what is the best practice for moving the green arrow. I have an image arrow.png and I guess I need to manipulate with the place that the picture is shown and with the rotation of the image.
Can someone point to me some guidelines ?
My basic idea is to have a relative layout for the background and to have one image view that will change the position, but the part changing position is little unclear to me. And I do not think that is good idea to play with layout params and margins...
I would probably extend ImageView then override your onDraw method and use canvas.rotate() to rotate the arrow depending on your app state.

Resources