Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update LibGDX version #117

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Expand Up @@ -5,9 +5,9 @@ sourceCompatibility = 1.6
sourceSets.main.java.srcDirs = [ "src/" ]

ext {
gdxVersion = '1.7.1'
gdxVersion = '1.9.8'
box2dlightsVersion = '1.4'
ashleyVersion = '1.6.1-SNAPSHOT'
ashleyVersion = '1.7.3'
}

dependencies {
Expand Down
29 changes: 22 additions & 7 deletions src/com/uwsoft/editor/renderer/SceneLoader.java
@@ -1,12 +1,11 @@
package com.uwsoft.editor.renderer;

import box2dLight.RayHandler;

import com.badlogic.ashley.core.Component;
import com.badlogic.ashley.core.Engine;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.EntityListener;
import com.badlogic.ashley.utils.ImmutableArray;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.Batch;
Expand All @@ -20,20 +19,37 @@
import com.badlogic.gdx.utils.viewport.ScalingViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.uwsoft.editor.renderer.commons.IExternalItemType;
import com.uwsoft.editor.renderer.components.*;
import com.uwsoft.editor.renderer.components.MainItemComponent;
import com.uwsoft.editor.renderer.components.NodeComponent;
import com.uwsoft.editor.renderer.components.ParentNodeComponent;
import com.uwsoft.editor.renderer.components.ScriptComponent;
import com.uwsoft.editor.renderer.components.light.LightObjectComponent;
import com.uwsoft.editor.renderer.components.physics.PhysicsBodyComponent;
import com.uwsoft.editor.renderer.data.*;
import com.uwsoft.editor.renderer.data.CompositeItemVO;
import com.uwsoft.editor.renderer.data.CompositeVO;
import com.uwsoft.editor.renderer.data.ProjectInfoVO;
import com.uwsoft.editor.renderer.data.ResolutionEntryVO;
import com.uwsoft.editor.renderer.data.SceneVO;
import com.uwsoft.editor.renderer.factory.EntityFactory;
import com.uwsoft.editor.renderer.physics.PhysicsBodyLoader;
import com.uwsoft.editor.renderer.resources.IResourceRetriever;
import com.uwsoft.editor.renderer.resources.ResourceManager;
import com.uwsoft.editor.renderer.scripts.IScript;
import com.uwsoft.editor.renderer.systems.*;
import com.uwsoft.editor.renderer.systems.ButtonSystem;
import com.uwsoft.editor.renderer.systems.CompositeSystem;
import com.uwsoft.editor.renderer.systems.LabelSystem;
import com.uwsoft.editor.renderer.systems.LayerSystem;
import com.uwsoft.editor.renderer.systems.LightSystem;
import com.uwsoft.editor.renderer.systems.ParticleSystem;
import com.uwsoft.editor.renderer.systems.PhysicsSystem;
import com.uwsoft.editor.renderer.systems.ScriptSystem;
import com.uwsoft.editor.renderer.systems.SpriteAnimationSystem;
import com.uwsoft.editor.renderer.systems.action.ActionSystem;
import com.uwsoft.editor.renderer.systems.render.Overlap2dRenderer;
import com.uwsoft.editor.renderer.utils.ComponentRetriever;

import box2dLight.RayHandler;

/**
* SceneLoader is important part of runtime that utilizes provided
* IResourceRetriever (or creates default one shipped with runtime) in order to
Expand Down Expand Up @@ -147,8 +163,7 @@ public SceneVO loadScene(String sceneName, Viewport viewport, boolean customLigh
if (!customLight) {
setAmbienceInfo(sceneVO);
}
rayHandler.useCustomViewport(viewport.getScreenX(), viewport.getScreenY(), viewport.getScreenWidth(), viewport.getScreenHeight());


return sceneVO;
}

Expand Down
@@ -1,19 +1,19 @@
package com.uwsoft.editor.renderer.components.sprite;

import java.util.Comparator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.utils.Array;
import com.uwsoft.editor.renderer.data.FrameRange;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class SpriteAnimationStateComponent implements Component {
public Array<TextureAtlas.AtlasRegion> allRegions;
public Animation currentAnimation;
public Animation<TextureAtlas.AtlasRegion> currentAnimation;
public float time = 0.0f;

public boolean paused = false;
Expand All @@ -22,7 +22,7 @@ public SpriteAnimationStateComponent(Array<TextureAtlas.AtlasRegion> allRegions)
this.allRegions = sortAndGetRegions(allRegions);
}

public Animation get() {
public Animation<AtlasRegion> get() {
return currentAnimation;
}

Expand All @@ -35,7 +35,7 @@ public void set(FrameRange range, int fps, Animation.PlayMode playMode) {
for (int r = range.startFrame; r <= range.endFrame; r++) {
textureRegions.add(allRegions.get(r));
}
currentAnimation = new Animation(1f/fps, textureRegions, playMode);
currentAnimation = new Animation<AtlasRegion>(1f/fps, textureRegions, playMode);
time = 0.0f;
}

Expand Down
Expand Up @@ -125,14 +125,14 @@ protected SpriteAnimationComponent createSpriteAnimationDataComponent(Entity ent

private Array<TextureAtlas.AtlasRegion> getRegions(String filter) {
// filtering regions by name
Array<TextureAtlas.AtlasRegion> allRegions = rm.getSpriteAnimation(filter).getRegions();
Array<TextureAtlas.AtlasRegion> regions = new Array<TextureAtlas.AtlasRegion>();
for(TextureAtlas.AtlasRegion region: allRegions) {
if(region.name.contains(filter)) {
regions.add(region);
}
}

return regions;
Array<TextureAtlas.AtlasRegion> allRegions = rm.getSpriteAnimation(filter).getRegions();
Array<TextureAtlas.AtlasRegion> regions = new Array<TextureAtlas.AtlasRegion>();
for (TextureAtlas.AtlasRegion region : allRegions) {
if (filter.contains(region.name.replaceAll("\\d", ""))) {
regions.add(region);
}
}

return allRegions;
}
}
@@ -1,22 +1,33 @@
package com.uwsoft.editor.renderer.systems.render;

import box2dLight.RayHandler;
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.Affine2;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.uwsoft.editor.renderer.commons.IExternalItemType;
import com.uwsoft.editor.renderer.components.*;
import com.uwsoft.editor.renderer.components.CompositeTransformComponent;
import com.uwsoft.editor.renderer.components.LayerMapComponent;
import com.uwsoft.editor.renderer.components.MainItemComponent;
import com.uwsoft.editor.renderer.components.NodeComponent;
import com.uwsoft.editor.renderer.components.ParentNodeComponent;
import com.uwsoft.editor.renderer.components.ShaderComponent;
import com.uwsoft.editor.renderer.components.TintComponent;
import com.uwsoft.editor.renderer.components.TransformComponent;
import com.uwsoft.editor.renderer.components.ViewPortComponent;
import com.uwsoft.editor.renderer.components.ZIndexComponent;
import com.uwsoft.editor.renderer.physics.PhysicsBodyLoader;
import com.uwsoft.editor.renderer.systems.render.logic.DrawableLogicMapper;
import com.uwsoft.editor.renderer.utils.ComponentRetriever;

import box2dLight.RayHandler;


public class Overlap2dRenderer extends IteratingSystem {
private final float TIME_STEP = 1f/60;
Expand Down Expand Up @@ -54,7 +65,8 @@ public void processEntity(Entity entity, float deltaTime) {
timeRunning+=deltaTime;

ViewPortComponent ViewPortComponent = viewPortMapper.get(entity);
Camera camera = ViewPortComponent.viewPort.getCamera();
Viewport viewport = ViewPortComponent.viewPort;
Camera camera = viewport.getCamera();
camera.update();
batch.setProjectionMatrix(camera.combined);
batch.begin();
Expand All @@ -66,6 +78,7 @@ public void processEntity(Entity entity, float deltaTime) {
rayHandler.setCulling(false);
OrthographicCamera orthoCamera = (OrthographicCamera) camera;
camera.combined.scl(1f / PhysicsBodyLoader.getScale());
rayHandler.useCustomViewport(viewport.getScreenX(), viewport.getScreenY(), viewport.getScreenWidth(), viewport.getScreenHeight());
rayHandler.setCombinedMatrix(orthoCamera);
rayHandler.updateAndRender();
}
Expand Down