A simple 2D game library made using Java Swing for Java Swing. In contrast to other 2D game libraries in Java this does not use OpenGL and instead uses Swing components/methodologies only. The allows you to be able to leverage existing knowledge of Java Swing components, layouts, UIs and design patterns in order to create a functional 2D game.
The projects nomenclature might seem familiar if you have ever used cocos2dx and thats because it is what inspired me to write this.
TODO (before beta release):
- Remove
Scenereference fromGameLoop - Iterate sprites using iterator or synchronized block in places that access sprite list
-
Sceneto render black background and not white - Add a
INodeinterface whichScenewill accept andSpritewill implement - Add a
ICollidableinterface which will allow automatic collision detections - Allow debug details/masks to be shown/drawn i.e FPS, objects rendered and red rectangles around all nodes when enabled
- Implement
AudioEngine -
INodeshould be able to be added to anotherINodeand rendered -
Sceneshould be nothing more then anINodewith aDirectorwhich extendsJPanelrunning the game loop and switching betweenScenes -
Nodeco-ordinates should be relative to parent.Scenenode should default by obtaining width and height from theDirector. - Implement
Animationloops as currently all animations run indefinitely -
ImageScalerto be first class citizen built intoDirector/Scene(so no point calcs for various screen widths are needed from a user perspective) -
parentshould be nulled whenNode#removeis called. - Checking for collisions should use a copy of the nodes as to avoid concurrent modification issues (when adding inside the
onCollisionmethod) - Add z-order to
Nodeas well as fix Node size counts -
Nodeshould haveonEnter/onExitcallbacks for when aNodeis made visible or removed from the scene/parent. - Remove any unnecessary synchronized blocks
- Rename all getters with world in to omit the world part for readability
- Add Spritesheet support for
SpriteFrameCache - Allow
Spriteto be created with a singleSpriteFrameas opposed to animation - Implement
setRestrictMovementToParent(boolean enable, long flags),setRestrictMovementToNode(INode node, long flags)andonMovementRestricted()forSprite, defaults to no restriction. - Implement
setFlippedYonSprite - Implement
setScaleforNode - Implement
setScaleXandsetScaleY - Allow
Scenebackground to be set with aSpriteFrameand SpriteFrame name similar toSprite - Add
MouseListenerability toNodes usingShape/Ellipses2D - Add
onCollisionStartandonCollisionEndmethodsICollidable - Investigate adding only necessary apache commons libraries
- Add
Camerawhich can be used for side scrolling/infinite background game types -
Sceneshould only render visible sprites in the camera view - Implement assets search paths (SD,HD,HDR)
- Allow
Directorto use variable or fixed time step game loop, as well as control FPS to 30 or 60. In fixed stepelapsedTimewill become 0 and interpolation in Node render will be >= 0 and vice versa. - Implement some type of
ActionManager/Actionableclass onNodewhichSpritewill use to switch out animations on the fly. Animate, MoveTo, Follow etc. - Allow more support of plist and TexturePacker formats like cropping and trimming of sprites, and rotated sprites as well as multi packed sheets
- Add Tileset/Tilemap support, which is used in its own sample (sample-2)
- Add physics capabilities using dyn4j
- Document classes and methods
Requirements:
Examples:
Special thanks to: