Exact pixel

Can anyone knows this?
I have an actor 150x50 pixels. I want to know the current pixel a ball bouncing on this actor. Is it possible?
Thank you
I have an actor 150x50 pixels. I want to know the current pixel a ball bouncing on this actor. Is it possible?
Thank you
Comments
Are you asking how to determine the pixel location of the actor on the stage?
a ball coming to the Actor 1, it hits it and bounce. I want to know the moment when hits the Actor 1, what pixel of this actor1 hits eg the 5th pixel, the 35th... I want, relevant to the side the ball hits, to change the angle of the bounce.
Thank you
First, lets say your example is a falling ball and a horizontal trampoline at the bottom of the screen. You need to set up a variable, call it TRAMPX. Then constrain TRAMPX to the X position of the trampoline. Set up a collision rule between the two actors, on the Ball. When it collides, subtract the difference between variable TRAMPX and the balls X position. If the ball is to the left of the center of the trampoline, this will give a +ve number. If it is to the right, it will give a negative number. This will tell you how many pixels away from the CENTRE of your trampoline your ball actor is when it collides. Now adjust the angle of the ball using this result (TRAMPX-self.position.x). You might have to do some math, e.g. to swap signs or introduce a multiplier depending on what effect you want to achieve.