{"id":13396050,"url":"https://github.com/Jawnnypoo/PhysicsLayout","last_synced_at":"2025-03-13T22:31:36.200Z","repository":{"id":30159991,"uuid":"33710270","full_name":"Jawnnypoo/PhysicsLayout","owner":"Jawnnypoo","description":"Android layout that simulates physics using JBox2D","archived":false,"fork":false,"pushed_at":"2024-01-17T09:58:15.000Z","size":1571,"stargazers_count":772,"open_issues_count":13,"forks_count":101,"subscribers_count":29,"default_branch":"main","last_synced_at":"2024-10-30T01:38:23.772Z","etag":null,"topics":["android","box2d","jbox2d","layout","physics","view"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jawnnypoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2015-04-10T05:31:35.000Z","updated_at":"2024-09-05T09:47:22.000Z","dependencies_parsed_at":"2024-01-31T23:03:35.981Z","dependency_job_id":null,"html_url":"https://github.com/Jawnnypoo/PhysicsLayout","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jawnnypoo%2FPhysicsLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jawnnypoo%2FPhysicsLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jawnnypoo%2FPhysicsLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jawnnypoo%2FPhysicsLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jawnnypoo","download_url":"https://codeload.github.com/Jawnnypoo/PhysicsLayout/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243213981,"owners_count":20254902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","box2d","jbox2d","layout","physics","view"],"created_at":"2024-07-30T18:00:38.416Z","updated_at":"2025-03-13T22:31:35.745Z","avatar_url":"https://github.com/Jawnnypoo.png","language":"Kotlin","readme":"# PhysicsLayout\nAndroid layout that simulates physics using [JBox2D](https://github.com/jbox2d/jbox2d). Simply add views, enable physics, and watch them fall!\n\nSee it in action with the sample app:\n\n[![Google Play](https://raw.githubusercontent.com/Jawnnypoo/PhysicsLayout/master/art/google-play-badge.png)](https://play.google.com/store/apps/details?id=com.jawnnypoo.physicslayout.sample)\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.jawnnypoo/physicslayout/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.jawnnypoo/physicslayout)\n\n## Gradle\n```groovy\ndependencies {\n    implementation(\"com.jawnnypoo:physicslayout:latest.release.here\")\n}\n```\n\n## Basic Usage\nIf you want to see what your layout looks like when physics is applied to it, simply change your root layout to a physics layout. \n```xml\n\u003ccom.jawnnypoo.physicslayout.PhysicsLinearLayout\n  android:id=\"@+id/physics_layout\"\n  android:layout_width=\"match_parent\"\n  android:layout_height=\"200dp\"\u003e\n            \n      \u003cImageView\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:src=\"@drawable/ic_launcher\"/\u003e\n\n      \u003cImageView\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:src=\"@drawable/ic_launcher\"/\u003e\n              \n      \u003cTextView\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"Hello world, I have physics!\"/\u003e\n            \n\u003c/com.jawnnypoo.physicslayout.PhysicsLinearLayout\u003e\n```     \n## Custom XML Attributes\nYou can also further customize the behaviour of your PhysicsLayout\n    \n```xml  \n\u003ccom.jawnnypoo.physicslayout.PhysicsLinearLayout\n  android:id=\"@+id/physics_layout\"\n  android:layout_width=\"match_parent\"\n  android:layout_height=\"200dp\"\n  app:physics=\"true\"\n  app:gravityX=\"0.0\"\n  app:gravityY=\"9.8\"\n  app:bounds=\"true\"\n  app:boundsSize=\"50dp\"/\u003e\n```            \n\n * `physics` boolean, Determines if physics will be applied to the layout (Default true)\n * `gravityX` float, Sets the gravity in the X direction (positive is right, negative is left) (Default 0)\n * `gravityY` float, Sets the gravity in the Y direction (positive is down, negative is up) (Default 9.8)\n * `bounds` boolean, Determines if the layout should have bounds on the edges of itself (Default true)\n * `boundsSize` dimenstion, Sets the width/height of the bounds on the edges (Default 20dp)\n\n## Custom Physics Configuration\nEach view contained within the layout has a physics configuration that it uses to create itself in the Box2D world. This defines its shape, mass, restitutaion, and other physics related variables. A custom configuration can be applied to each view as well:\n```xml\n\u003cTextView\n  android:id=\"@+id/text\"\n  android:layout_width=\"20dp\"\n  android:layout_height=\"20dp\"\n  app:layout_shape=\"circle\"\n  app:layout_circleRadius=\"20dp\"\n  app:layout_bodyType=\"kinematic\"\n  app:layout_fixedRotation=\"true\"\n  app:layout_friction=\"0.8\"\n  app:layout_restitution=\"0.3\"\n  app:layout_density=\"0.5\" /\u003e\n```\nor alternatively, the Physics definition can be made programmatically:\n```kotlin\nval circleView = findViewById\u003cView\u003e(R.id.circle)\nval config = PhysicsConfig(\n    shape = Shape.CIRCLE,\n    fixtureDef = fixtureDef,\n    bodyDef = bodyDef\n)\nPhysics.setPhysicsConfig(circleView, config)\n```\n\nThis is useful especially if you have view that would be considered circular, as the default for all views is a RECTANGLE shape. Most of the time, if you are just dealing with rectangular views, the defaults will work for you and you will not have to worry about this.\n\nCheck out the sample app to see most of these things in action.\n\n## Making a Game?\nThis library was designed with the intention of allowing for playful animations within normal Android apps. It is not built to be a game engine or meant to compete with the likes. If you are looking to do more intense mobile games, we recommend libraries such as [libGDX](https://libgdx.badlogicgames.com/) or [Unity](https://unity3d.com/)\n\nLicense\n--------\n\n    Copyright 2024 John Carlson\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","funding_links":[],"categories":["Index `(light-weight pages)`","Libraries","Index","Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJawnnypoo%2FPhysicsLayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJawnnypoo%2FPhysicsLayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJawnnypoo%2FPhysicsLayout/lists"}