In this particular code if for mouse.move command I am giving argument 1100/500 it is moving toward right and if I am giving argument as 100/500 it is moving towards left doesn't matter where the target position is. Even for 500/500, it is moving toward the right, what does it mean?
keyboard ⋘WIN+D⋙
mouse.click 336⫽49 relative false type down
mouse.move 1100⫽500 wait 1000 relative false
mouse.click 1819⫽870 relative false type up
In this example mouse.move won't make a big difference to the whole automation because you have ordered a robot to press the left mouse button at the 336⫽49 position and then move somewhere randomly (to the 1100⫽500 position) and finally move to the 1819⫽870 position and unpress the left mouse button.
Related
I'm trying to make a health bar that decreases from left to right instead of from right to left
and it has to be this way because of how the interface looks, I've tried different calculations but all of them were close but too far and I'm running out of ideas on how to make it
Take a look into anchor point.
What anchor point does is set the origin of the UI. So for your use case, you'll probably want to set the anchor point to [1,0]. Which means the UI will scale to the left
(White Box) Anchor point 0,0
(White Box) Anchor point 1,0
With an anchor point of 1,0, it will scale to the left
What am I trying to achieve?
I have a Sprite which is supposed to move with the mouse position (kinda like a cursor). In my case though I also have some other Textures (Obstacle-class). So if the mouse collides with such an obstacle I want the texture to stop moving in that direction.
What is the problem?
While the texture does follow the mouse and also does stop when the mouse "collides" with an obstacle, at some point the cursor is not within the Bounding Rectangle anymore, but on the other side of a wall for example. The consequence, the texture's position is updated to the mouse position and it suddenly appears behind the wall which is not a desired behavior.
My collision method.
private void CheckCollision(List<Obstacle> _obstacleList, MouseState mState)
{
int xOffset = oldMouseState.X - mState.X;
int yOffset = oldMouseState.Y - mState.Y;
Vector2 offsetPosition = new Vector2(oldMouseState.X + xOffset,oldMouseState.Y + yOffset);
bool collides = false;
foreach (Obstacle obstacle in _obstacleList)
{
if (obstacle.BoundRectangle.Contains(offsetPosition))
{
collides = true;
}
}
if (!collides)
{
position = offsetPosition;
}
}
Question
What be a way to prevent the sprite to move through walls in my case?
Thanks in advance.
As you know, you can read the the mouse position by calling Mouse.GetState(). But you can also set the mouse position to whatever you want through Mouse.SetPosition(X,Y) and the mouse will go there.
So, if you are up against, say, an X barrier (vertical barrier), simply call
Mouse.SetPosition(oldMouseState.X, mState.Y);
and your mouse will not change its X value even if pushing your mouse in that direction, it will not go through the wall at all but it is allowed to go up and down just fine.
If you back off from the wall, simply don't call this line and it will operate like befor.
You could store the last (valid) known position of the mouse and the current position of the mouse (valid means the mouse isn't in a rectangle where it shouldn't be). When you hit a rectangle that the mouse shouldn't pass through with your current mouse position, you iterate back to the last valid position in a while loop and check if the mouse is still in the blocking sprite every time you moved the mouse closer to the valid position. If the mouse is outside the forbidden zone, you just exit the while loop and the mouse is quite close to the border of the obstacle.
Having a ChartSeries, I would like display a certain text on a label moving the mouse above the ChartValues. But only the line is active for me and not the EndPoint (definitely the Value…)
I would like if the EndPoint (a Circle, actually) would be active instead of the line and moving the mouse above this circle, my text can be appeared. Thanks.
You could try the MarkTips tool.
If you have a TLineSeries with Pointer.Visible=true, the mark tips tool will appear when you have the mouse over the line and over the pointer. If you only want it when you have the mouse over the series pointer, you could have a TLineSeries with Pointer.Visible=false and also a TPointSeries with the same data, and the MarkTips tool assigned to the TPointSeries.
Every time I change .string property of my CCLabelBMFont object, the position is updated. So if I want to show updating lapsed time, then time is changing position on each update.
How can I maintain position of CCLabelBMFont while changing string value?
the position of the node should remain the same till you change it somehow. I suppose you mean that text position is related to its length. Try to set anchor point of the label. If anchor point set to 0,0 (left bottom corner) then when text length will grow its position will remain the same.
P.S. you can use different anchor point values to achieve alignment that you need
So i have a custom UISlider. It's vertical (i did it with the +270° technic). I have 3 images, respectively for the minimum value, maximum value and for the thumb. Everything seems good but i have problems with the extrema values, as you can observe on the screen capture (even though it's a little dark).
The slider on the left is perfect ! Both end of the sliders show the images perfectly and the cursor (thumb) is perfectly cutting the slider in 2.
The other two sliders on the right shows a similar issue. We can see that, when in extrema value, the cursor is not well located (there shouldn't be any part of the image below or above the middle of the cursor !) Oo
More to that, let's look at the right slider (with minimum value). We can see that image has been cut on the bottom ! Indeed it should be close. It's the same thing for the maximum value, the image looks like it's been cut.
I looked at the bounds of the slider view by touching it at both ends and looking at its coordinates. The slider was defined with a height of 300 but i can perform touches at coordinate 307, or -6 !!! I don't really understand why..
For more information, coordinates form 300 to 310 represents the maximum value i defined and negative coordinates (from 0 to -10) represents the minimum value.
-> So We can notice there's a difference of 10 at both ends.
Please help ! :s