java - Libgdx: How to access/modify Box2D World from another input processing class? -


i'm working on small game , i'm trying keep things neat possible. i've split inputprocessor class , works fine. i've setup playstate class handles , creates bodies , fixtures box2d.

and in input processing class:

public class touchprocessor implements inputprocessor  {      //.....      @override         public boolean touchdragged(int screenx, int screeny, int pointer) {             system.out.println("dragging...");             touchhappening = true;              return true;         }      // .... 

now on touch drag, want reposition body/camera box2d world. don't have access in processor class if separate playstate. how go this?

every time when decouple application parts (which idea btw) need strategy how different parts can work together.

an solution seen in wild use kind of central singleton make important game methods accessible other code. singletons have own flaws. way use kind of event system here.

you may want have @ these decoupling patterns ideas game architecture.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -