Can I click on the sprite?
Can I click on the sprite?
Can I click on the sprite? Can I get the coordinates of the click relative to the "OpenWindowedScreen" window to see if the sprite was clicked?
Re: Can I click on the sprite?
From the screen.sb example, it is ALSO clear that the only event available is #PB_Event_RenderFrame, and the SetFrameRate(XXX) function sets the frequency of these events. And then all that is available in the Mouse library.
2B or not 2B = FF
Re: Can I click on the sprite?
I tried using a sprite for the game "fifteen", but there was a poor touch screen response, so I did using Canvas. The archive contains the source.
Changed SetFrameRate(60), it became normal.
Instead of lightly touching the screen, I had to hold my finger for a long time to move the sprite. This means that "SetFrameRate" affects not only the frequency of the animation, but also the frequency of the finger tap check.
You need to specify this in the help file, since my program has little animation and the frequency is not important, but it is important that it affects the reaction time of clicking on the screen.
Changed SetFrameRate(60), it became normal.
Instead of lightly touching the screen, I had to hold my finger for a long time to move the sprite. This means that "SetFrameRate" affects not only the frequency of the animation, but also the frequency of the finger tap check.
You need to specify this in the help file, since my program has little animation and the frequency is not important, but it is important that it affects the reaction time of clicking on the screen.
Code: Select all
EnableExplicit
Procedure RenderFrame()
Protected k
Static SpriteFinger = -1
Static x, y
If ExamineTouchScreen()
For k = 0 To 4
If TouchScreenPushed(k) And SpriteFinger = -1
SpriteFinger = k
EndIf
Next
If SpriteFinger <> -1 And TouchScreenPushed(SpriteFinger)
x = TouchX(SpriteFinger) - SpriteWidth(0) / 2
y = TouchY(SpriteFinger) - SpriteHeight(0) / 2
Else
SpriteFinger = -1
EndIf
DisplaySprite(0, x, y)
FlipBuffers()
Else
Debug "Touch screen not detected"
EndIf
EndProcedure
Procedure Loading(Type, Filename$, ObjectId)
Static NbLoadedElements
NbLoadedElements+1
If NbLoadedElements = 1
FlipBuffers()
EndIf
EndProcedure
Procedure LoadingError(Type, Filename$, ObjectId)
Debug Filename$ + ": sprite loading error"
EndProcedure
OpenScreen(340, 540, 32, "Test")
SetFrameRate(60)
ClearScreen($3f3f3f)
BindEvent(#PB_Event_Loading, @Loading())
BindEvent(#PB_Event_LoadingError, @LoadingError())
BindEvent(#PB_Event_RenderFrame, @RenderFrame())
LoadSprite(0, "./data/sprite.png")
Re: Can I click on the sprite?
How to test the work of sprites? It takes me a lot of time to compile and install the program on my phone. Do I need to make a PureBasic analogue of the program in order to test the code using the ExamineMouse() functions?
Re: Can I click on the sprite?
You can also use ExamineMouse() in SpiderBasic and test in the browser