Coder Social home page Coder Social logo

flame_forge2d's Introduction

This repostitory has moved to the Flame monorepo

flame

Flame Forge2D - The bridge between Flame and Forge2D

Test

This library acts as a bridge between Forge2D (our port of Box2D) and the Flame game engine.

Installation

Add the following to the dependencies section of your pubspec.yaml file:

dependencies:
  flame: ^1.0.0-releasecandidate.12
  flame_forge2d: ^0.7.2-releasecandidate.12

Examples

In the example folder of the repository you can find some examples, and you can also find some examples in the Forge2D repository.

Documentation

Some more documentation can be found on https://flame-engine.org/docs/#/forge2d

flame_forge2d's People

Contributors

erickzanardo avatar g0rdan avatar luanpotter avatar spydon avatar vidhanth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flame_forge2d's Issues

Proper way of adding the flame_forge2d dependency

Right now, it doesn't seem flame_forge2d has been published to pub.dev. Should I simply clone this repo into my project and reference via relative path in pubspec.yaml? Something like

dependencies:
  flutter:
    sdk: flutter
  flame_forge2d:
    path: flame_forge2d

Can't run example

image
I trying to play-around with this package but got so many issues.

Error importing viewport

The latest version 0.6.4-rc4 is not compatible with the latest flame 1.0.0-rc8. Getting the following error,

Error: 'Viewport' is imported from both 'package:flame/src/game/viewport.dart' and 'package:flame_forge2d/viewport.dart'.
import 'viewport.dart';

Error: Method not found: 'SpriteComponent.fromSprite'.
) : super(SpriteComponent.fromSprite(spriteSize, sprite), spriteSize);

Not able to run Example

Hello,

Tried running it directly from the parent package and got some errors, so specifically went to example folder and altered pubspec.yaml per the previously closed issue and got an error again. your time is much appreciated, thanks in advance!

image

The sample is not working anymore

A lot of error occur when I download and run it.

lib/draggable_sample.dart:40:26: Error: Type 'DragEvent' not found.     
  bool handleReceiveDrag(DragEvent event) {                             
                         ^^^^^^^^^                                      
lib/draggable_sample.dart:50:22: Error: Type 'DragEvent' not found.     
  bool onReceiveDrag(DragEvent event) {                                 
                     ^^^^^^^^^                                          
lib/mouse_joint_sample.dart:38:22: Error: Type 'DragEvent' not found.   
  void onReceiveDrag(DragEvent drag) {                                  
                     ^^^^^^^^^                                          
../lib/forge2d_game.dart:10:1: Error: 'Viewport' is imported from both 'package:flame/src/game/viewport.dart' and 'package:flame_forge2d/viewport.dart'.
import 'viewport.dart';                                                 
^^^^^^^^                                                                
lib/position_body_sample.dart:59:33: Error: The parameter 'details' of the method 'PositionBodySample.onTapDown' has type 'TapDownDetails', which does not match the corresponding type, 'TapDownInfo', in the overridden method, 'Forge2DGame with
TapDetector.onTapDown'.
 - 'TapDownDetails' is from 'package:flutter/src/gestures/tap.dart' ('../../../flutter/packages/flutter/lib/src/gestures/tap.dart').
 - 'TapDownInfo' is from 'package:flame/src/gestures/events.dart' ('../../../flutter/.pub-cache/hosted/pub.dartlang.org/flame-1.0.0-releasecandidate.11/lib/src/gestures/events.dart').
Change to a supertype of 'TapDownInfo', or, for a covariant parameter, a subtype.
  void onTapDown(TapDownDetails details) {                          

ChainShape in circle_stress_sample.dart

I ran circle_stress_sample.dart from the spydon.update-versions branch.
I deleted the left side of the two CornerRamps, and the right side shows up, but the hit decision is on the left side.

Future<void> onLoad() async {
    final boundaries = createBoundaries(viewport); 
    boundaries.forEach(add);
    add(CircleShuffler()); 
    add(CornerRamp(isMirrored: true));
    // add(CornerRamp(isMirrored: false)); 
}

BodyComponent prepareCanvas Method Throws UnimplementedError

Build 0.7.2--releasecandidate.12 of the flame_forge package throws an UnimplementedError from the abstract class BodyComponent. This bug was introduced in the "Update to rc 12" commit 4058eaca79ba1b648120bcfe839624e9aa5f0110. The bug is in line 58 of body_component.dart:

   if (_transform.m14 != body.position.x || 
       _transform.m24 != body.position.y ||
       _lastAngle != angle) { 
     _transform.setIdentity();  
     _transform.scale(1, -1);          // <- THIS IS THE BUG CAUSING THE UNIMPLEMENTEDERROR
     _transform.translate2(body.position); 
     _transform.rotateZ(angle);
     _lastAngle = angle;
   }

The UnimplementedError is being thrown because the Matrix4 scale method doesn't support integer values for the x parameter. The method signature is:

   void scale(dynamic x, [double? y, double? z])

The x parameter must be a Vector3, Vector4, or a double otherwise, an UnimplementedError is thrown.

Box2d wants meters but flame wants pixels

When this mapping is not done properly Box2d behaves in unexpected ways, but dealing with both coordinate systems in multiple places is confusing. I suggest a single place in flame_forge2d where the caller can define the value of pixels-per-meter. Perhaps as an optional parameter to the Forge2dGame constructor. Flame users can continue to deal with existing flame apis in pixels, and flame_forge2d can do all the conversions for us.

Couldn't run the example

I couldn't run the example. It has some compile time errors. Please fix.

I'm using flutter 2.0.1 & dart 2.12.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.