ClickerMonkey Forums/Monkey Beginners/Clicker
| 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 :) |
| Are you after a code example? Maybe Pakz has one in his blog:|
| 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 |
| Totally possible with Monkey-X. |
| 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.
| Thankyou, I'll try this out later! |