Hi I am trying to add a simple enemy AI to my platform game - the enemy should run towards the player from the left or the right of the screen (depending on it´s position) and pause it´s movement if he collides with him or something else.
However the main question is how can I achieve something like this? I know how to dispatch custom events but the main problem is the basic structure of my enemy AI. In my game there are many objects updating their positions every frame (like layers), so I am searching for a not so performance heavy method 
I couldn´t find any basic AI tutorial on the web so I am asking directly.
P.S.: I am using Perspective to achieve my parallax effect and I am currently adding the enemy objects to the second layer but the player is moving on the first one.
Do they have to be in the same layer to update their positions correctly?
As already said I do not want something like mentioned in “The nature of code”, just some basic AI mechanics for moving the newly spawned enemy towards the player.
Help is appreciated,
Max