Monkey Forums/Monkey Beginners/Clicker

ewancordiner(Posted 2016) [#1]
Hi, relatively new to Monkey X and was just wondering how to make an image be presented in the middle of the screen and when the player clicks on it, a counter ticks up by 1 each time, thankyou :)

MikeHart(Posted 2016) [#2]
Are you after a code example? Maybe Pakz has one in his blog:

ewancordiner(Posted 2016) [#3]
Hi, yes as I have a programming project for my a level and was looking at making a cookie clicker like game and yeah I shall have a look, just looking for a sort of code so I could click an image increasing a counter and then dave this to a potential game save file? Just wondering if this was possible within monkey

MikeHart(Posted 2016) [#4]
Totally possible with Monkey-X.

Gerry Quinn(Posted 2016) [#5]
Just look at the simplest app examples ('bananas') for basic setup. Set up a class that extends App, and create an instance of it in Main().

Make an OnCreate() method for your class, and load your image using LoadImage() function. You might also check screen sizes [DeviceWidth(), DeviceHeight() functions] and decide on positions so you don't have to do it every frame. In OnRender(), display it. In OnUpdate(), check for clicks using the MouseHit(), MouseX() and MouseY() functions, and update your counter (a field in your app).

Saving is a bit limited on some platforms, but on the desktop platform you can use some of the BRL functions to save to an ordinary file.

ewancordiner(Posted 2016) [#6]
Thankyou, I'll try this out later!