How to track an actor from the left of the screen? - gamesalad

How can I make the camera start tracking my actor starting from the left side of the screen; not when he reaches the middle?
As you can see, the tracking area is in the middle of the screen and I'm not able to move it so it can align with the actor in the far left of the screen, i.e when the actor starts moving I want the camera to start tracking him instantly and not wait till he reaches the middle.

The way I've done this in the past is to create an invisible actor and constrain it to to the actor's position + 50% of the screen width, and then track that invisible actor with the camera

Related

How to pan openseadragon mutli image viewer within the bounds

I have a multi image openseadragon viewer, where the coordinates of each tiled image seem to be calculated based on the size of the image to the container viewer size. When the user clicks on a specific image I am trying to fit the image to the center of the viewport by using fitBounds method. Here I am passing the bound rect of the image the user has clicked. This is working perfectly. Now I have a requirement where say a panel is placed on the right side, on top of the viewer, I need to consider the boundary till the left of the panel(Viewer area includes the area under the right side panel). What this means is that, though the viwer need to occupy full width, the image that need to be fit should concider only the center between the left of the viewer upto left of the panel(excludes the area under the panel). I tried doing PanTo but couldn't understand how to calculate the center for a multi image scenario.It doesn't seem to be accurate. The x coordinate of the 4th image seem to be at 4.9 and am trying to see how I can calculate a correct coordinate center for each image where I can panTo. Can someone point me in the right direction?

positioning a movieclip relative to another movieclip

I have two movie clips on the stage and what I'm trying to do is position the second mc relative to the left of the other (the first one's width is 24px, while the second one is 151px)
I thought the way to do this was by giving the second mc the x of the first then subtracting the width from the second mc x, but it doesn't seem to be working. how does as3 calculate x positioning of an mc? is it from the center of the mc out or is it using the origin point somehow?
When you create a movie clip there is a registration point created in the process which is where all transformations of this type are referenced from.
If you are creating the movie clip in the Flash environment rather than code you can select which position to create this point when you are creating the movie clip. There is a square grid which allows you to choose this. I usually like to use the top left so when you do:
moveclipA.x = movieclipB.x - movieclipA.width
then you will get it positioned exactly next to the left movieclipB.
How are your movieclips positioned? Are they layered on top of each other? If so I suspsect that your registration point is at the centre. To solve this you can multiply the distance it is moving to the left by 2

Setting the stage to scroll horizontally left or right to show content when button is clicked?

I want to create a flash site where I have a long horizontal movie clip split into about five sections, each about 960px wide. The effect I want to achieve is when the user clicks on the button it will scroll horizontally to the specific section of the flash project. For example, if your on the home page and you click on the contact the movieclip will tween to the right until it reached the contact section of the long movieclip. And I also want it where if the user clicks on the home it'll scroll back to the home page. I can't seem to accomplish. I tried positioning with the x property and move right so many pixels. I'm thinking about setting like some coordinates or some kinds of reference points so when the button is clicked it will go to those specific points in the stage.
what you have to do is
create a container MovieClip/Sprite add it to stage
add all five MovieClips to this container
set x positions for each child. child1 - 0, child2 - 960, child3 - 1920, child4 - 2880, child5 - 4800
move container to 0, 960, 1920, 2880, 2880 to show child MoviClips 1 to 5 as needed
If needed use a library like TweenLite for cool transition

HTML5 Canvas animations which animate off of the edges and return seamlessly?

I have many different elements floating around a page at different speeds. When an element leaves the right hand side of the page, it should start to float in the left hand side. This is easy, if the element.x is bigger than canvas.width, element.x = -100. This sets it a little further out so it doesn't look jumpy. But now here is the problem, how do I do it if the element leaves the left hand side of the page? We cant say if element.x < canvas.width because some elements will naturally be on the outside of the canvas floating back in.
Thanks for your help
There are a few ways to go about this.
One is to only "move" the element to the other side if it is completely offscreen (if there is zero intersection). Then moving it means that you always intersect the screen by only one pixel.
Another is to check "where it was coming from" by keeping track of its last location or knowing its trajectory (you probably know this if you're animating). If it is coming from the left and going to the right and you're on the right side, its leaving the screen and you have to move it. But if its coming from the left and going to the right and you're on the left side of the screen, you know its entering and its OK.

Swing rotate border

I'm working on a swing program to display several pictures. And one can rotate the picture (implemented each as a JComponent).
Problem is, when a picture gets rotated, the border of the JComponent doesn't change so that the picture gets clipped.
Is there any way to also rotate the border so that the picture can be fully drawn?
(I know one can calculate the new size of the border, but it leaves empty space on the edge. When a rotated picture overlaps with another and one want to move the one underneath, one cannot do that because the event will be passed to the picture above, onto the transparent edge. So it is more ideal if one can just rotate the border).
Execute another pack() on your top-level JFrame after rotating.