This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

RcCookie
RcCookie presents ...

2020/12/8

Project: UI

This scenario includes a lot of useful UI elements as well as the displayed demo. There is a lot of documentation in the source code.

TO REUSE THIS SIMPLY COPY THE 'rccookie' FOLDER INTO YOUR SCENARIOS FOLDER!

The UI includes:
- A text button
- A image button
- A simple text
- A drop-down menu
- Design themes (--> dark mode!!!)
- A fps display
- A keyboard based UI navigation (press TAB!)(Better not use it on the menu ;-) )
- A slider (currently not working)

The design is highly based on the Windows UI, with the only thing not working being the font.

Everything is easily reusable in your scenario and does has minimal cpu demand. This is because all the images used are either cached or generated only „on demand“ and if they changed.

2914 views / 22 in the last 7 days

1 vote | 0 in the last 7 days

Tags: mouse physics demo with-source click gui button interface

This scenario is a member of: Reusable classes


open in greenfoot
Your browser does not support the canvas tag.
HissssHissss

2020/12/9

This is my first time trying to import a whole new class like this and I'm not sure how to do it. Can you help me out? I've tried numerous things for over an hour and just can't quite get it. What I'm trying to do is stitch this together with my project as an overlay that gets called automatically, but it keeps competing with the world that I already have and really have no clue. Do I have to redo all my classes under this one so they are called correctly?
RcCookieRcCookie

2020/12/9

No, this is based on java packaging. This is basically like a folder system. Therefore, copy the whole „rccookie“ folder into your project, so that the structure is like YourScenarioFolder |-images |-rccookie |-MyWorld.java |-MyWorld.class |-project.greenfoot |-More of your classes Then you can import a class from the package like this: // At the very top of the file just like the greenfoot import import rccookie.ui.basic.Button; This way you import the Button class. You can also write import rccookie.ui.basic.*; import rccookie.zu.advanced.*; import rccookie.ui.util.*; To import absolutely everything about the ui. Actually the import greenfoot.*; statement works exactly the same, only that is does not reference a folder in your scenario‘s folder. You can also take a look into the MyWorld source code in my demo to see how I did this.
HissssHissss

2020/12/9

I understand the folder packaging and the importing, but am having trouble actually getting it to instantiate on the screen. I'll go ahead and copy paste my usual code over to form a title image and hope you can help me from there. I have since deleted the original code I used to try and instantiate the fancy screen, but all I need are two buttons if you can help me out. The code I pasted is used to handle switching between rooms in the game I am making if that helps. import greenfoot.*; /** * This class is used to initialize and control changing of worlds */ public class ControlWorld extends World { static Actor kara; // an actor to be passed from world to world Portal portalLeft, portalRight, portalUp, portalDown; Actor btnExit, btnStart; /** * This initial world constructor starts the control of changing worlds for the rooms. */ public ControlWorld() { super(800, 600, 1); kara = new Kara(); String text = "\nAlex His APCSA Project"; GreenfootImage img = new GreenfootImage(text, 40, Color.BLACK, new Color(0, 0, 0, 0)); getBackground().drawImage(img, 400-img.getWidth()/2, 150); } public void act() { World world = new Room1(); world.addObject(kara, getWidth()/2, getHeight()/2); Greenfoot.setWorld(world); } /** * This continuation constructor is used to go from one world to the next. * * @param wide the width of the new world (in cells) * @param high the height of the new world (in cells) * @param cellsize the size of a single cell in the new world (in pixels) */ public ControlWorld(int wide, int high, int cellsize) { super(wide, high, cellsize); } }
RcCookieRcCookie

2020/12/9

Say you want to switch between worlds with a button. Then all you need is something like this in the constructor: addObject(new TextButton(„Switch world“).addClickAction(m -> Greenfoot.setWorld(new SecondWorld())), 300, 350); This will initialize and set a new world named SecondWorld
HissssHissss

2020/12/9

Thank you, it works like a charm!
RcCookieRcCookie

2020/12/9

Great!
RcCookieRcCookie

2020/12/9

By the way, if you want your text to have the same design as the buttons, you can use the Text class. For example: addObject(new Text("\nAlex His APCSA Project", 40), 400, 150); would replace your title drawing in the constructor. Text is in rccookie.greenfoot.ui.basic;
HissssHissss

2020/12/10

Thank you! The project is sadly due today, so I cannot really explore too much more in your UI, but there is a very good chance I will come back to it later because I'm actually really proud of this one. It's my first knock-off lol.
RcCookieRcCookie

2020/12/10

Thanks! Happy you like it!
ZAKSAL200ZAKSAL200

2024/5/27

Hisss you actual loser. it's supposed to be a Capital you absolute baffoon.

See all comments

Want to leave a comment? You must first log in.

Who likes this?

Game/maniac