Simple control at the bottom

Monkey Forums/Monkey Programming/Simple control at the bottom

Fryman(Posted 2012) [#1]
Im trying to put in a really simple control for touch screens but id like the choice of it being at the top of the screen or bottom but for the life of me I cannot work out the maths on how to do it at the bottom.

For the top it is the following

PositionX = MouseX() * 2
PositionY = MouseY() * 2


The top left is pretty much spot on but the object moves twice as fast as the finger, which is exactly what I want but at the bottom.

The X is going to be the same but the Y I just cannot seem to fathom


Fryman(Posted 2012) [#2]
Ahh solved it, seems hacky to me but works


Method TerribleMaths:Float()
	'Terrible maths for the Y joystick
Local MouseMod:int = 2
	
	'Step one get Y 
	Local A:int = MouseY()

	'Step 2 - it from 480 to reverse it so you are not working upside down
	Local B:Int = 480 - A

	'Step 3 * it by mousemod
	B = B * MouseMod

	'Step 4 Reverse it again
	A = 480 - B


	Return A
	
	
End Method




DPbrad(Posted 2012) [#3]
y=DeviceHeight()-((DeviceHeight()-MouseY())*2)



Fryman(Posted 2012) [#4]
Yes thats much better, I should of thought of that

Thanks Muchly