Thanks for replying!
(Slight typo in my first post, it should ofc be "AGK", not "APK")
Markus:
The google play store doesn't say "update" so I guess I have the latest player. At the bottom of the player screen (when starting the player) it says "10000008 build Aug 6 2013".
If memory serves, it worked just as good (or bad) with the AppGameKit 2, I didn't know there was another player around for that one.
My Android version is 4.2.2.
Naphier:
Thanks for that! It doesn't work any better than the other one, but at least it's a starting point for figuring out things.
It seems I got it the other way around, it seemingly is the py# variable that works, except it think it is px# (reacting when moving the finger, or the S-pen, horizontally).
The px# (or getPointerX()) is reacting as if it is the getPointerState(), showing "0" (zero) when not touching the screen, and "1" when I touch the screen. No floating points, just 0 or 1.
The value for py# shown on screen is also an integer, 10 digits long. From about 1065353216 (leftmost) to 1151328256 (rightmost). This was in landscape mode. About the same if started in portrait mode, except rightmost value is "slightly" less at 1145552896.
Resolution of the screen is 1280x800 btw.
So it seems getPointerY() actually accesses some kind of X value, while getPointerX() is getPointerState().
The real getPointerState() only reacted when I lifted the finger (or pen) up from the screen. Then for a very brief moment I can see some numbers flashing by, and the sprite changing direction a bit (not the correct direction as it lacks the real px# value ofc).
It didn't seem to make any difference using the S-pen. It is pressure sensitive, but I didn't see any difference in either the px# or the pointerstate value. When I lifted the finger (or pen) from the screen it also took on a 10-digit (ish) number (see slightly modified code below - printing the pointerstate to the screen - ofc you have to have the same tablet, or a similar one maybe).
I guess (but don't know) pressure sensitivity isn't supported by the AGK. And it seems the addresses of which to access the X and Y etc positions is a bit different in this device (or possibly Android version?).
Modified your code snippet a bit. One thing I found is that I could not use
print("Pointer state = " + str(pointerState))
Not sure if its the "str" function or print() itself that protests. As sais I got an error "unknown instruction 649". Commenting out the print statement fixed it (the if block worked).
But changing "pointerState" to a float also works for printing:
print("Pointer state = " + str(pointerState#))
Code snippet:
SetVirtualResolution( getDeviceWidth(), getDeviceHeight() )
spr = createSprite( 0 )
setSpriteSize( spr, 10, 50 )
setSpriteOffset( spr, 5, 50 )
rem position in the screen centre
centreX# = getDeviceWidth()/2.0 //always use # when dealing with floats and always use decimal constants in case AGK tries to convert to integer for some horrible reason
centreY# = getDeviceHeight()/2.0
setSpritePositionByOffset( spr, centreX# , centreY# )
rem Main game loop
do
print("centreX# = " + str(centreX#))
print("centreY# = " + str(centreY#))
rem get mouse pointer position and state
px# = getPointerX()
py# = getPointerY()
pointerState# = getPointerState() // Had to use a float for the print statement below.
//let's use print to tell us what is happening
print("px# = " + str(px#))
print("py# = " + str(py#))
print("Pointer state = " + str(pointerState#))
//print("Pointer state = " + str(pointerState)) // Worked on PC when integer variable but not on tablet Samsung Galaxy Note 8 - "Unknown instruction 649"
//print("Pointer state = " + str(GetPointerState())) // Exactly the same here, works on PC but not on the tablet.
//this should really wait until you've pressed the mouse / screen
if pointerState# > 0
rem calculate angle between mouse and sprite
dx# = px# - centreX#
dy# = py# - centreY#
angle# = atanfull( dx#, dy# )
//print("")
print("dx# = " + str(dx#))
print("dy# = " + str(dy#))
print("angle# = " + str(angle#))
rem set the sprite angle
setSpriteAngle( spr, angle# )
endif
rem update and render
Sync()
loop
So I guess it's time to report something to the AppGameKit people.. not sure where or how to do that yet. Unless they also peruse these forums (I see you have a "AGK developer" text by your nick?).
(Hope this post isn't as messy to read as it was to write
)