Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - sheep42

Pages: [1]
1
help / Re: [Flixel-GDX] Pointer Issues [RESOLVED]
« on: Sun, Mar 13, 2016 »
Was able to fix this by calling FlxG.mouse.load(); on window resize.

2
help / [Flixel-GDX] Pointer Issues [RESOLVED]
« on: Sat, Feb 27, 2016 »
Hi There,

I'm having some odd issues with the mouse pointer in my game and I'm hoping someone might be able to help me out.

When I have the game running in the default window things work perfectly, however when I resize or maximize the window the mouse pointer becomes offset. I am suspecting this might be something to do with LibGDX as it seems like the system pointer is also offset when I show it. When the button is hovered it will activate a hover state and turn the button white. I have temporarily shown the system pointer on top of the Flixel pointer for demonstration purposes.

Here's a screenshot of the window at it's starting size (working properly):



Here's a screenshot of the maximized window(offset issue):



As you can see in the attachments, when the window is maximized, the flixel pointer is drastically offset from the system pointer and neither pointer is triggering the hover state at the proper position. The same issue carries over mobile touch events. Any help would be greatly appreciated.

Thanks!

3
help / Re: Moving a Hero in a game
« on: Sat, Nov 21, 2015 »
I would do it by applying a constant x velocity and then modifying the x acceleration on key press. When no keys are pressed you can check the velocity and modify the acceleration accordingly. This is written in Flixel-GDX, meaning this is Java code, but it shouldn't be too difficult to change the syntax if you're in AS3 or Haxe. 

Code: [Select]
public class PlayState extends FlxState{
FlxSprite player = new FlxSprite(100, 100);

@Override
public void create(){
player.makeGraphic(20, 20, FlxG.BLUE);
player.velocity.x = 100;
add(player);
}

@Override
public void update(){
                //Screen Wrap
if(player.x >= FlxG.width + player.width){
player.x = -player.width;
} else if(player.x <= -(player.width+1)) {
player.x = FlxG.width;
}

                //Handle key presses
if(FlxG.keys.pressed("LEFT")) {
player.acceleration.x = -50;
} else if(FlxG.keys.pressed("RIGHT")) {
player.acceleration.x = 50;
} else {
                        //Check velocity and get back to the constant velocity
if(player.velocity.x > 100){
player.acceleration.x = -50;
} else if(player.velocity.x < 100) {
player.acceleration.x = 50;
} else {
player.acceleration.x = 0;
player.velocity.x = 100;
}
}

//Cap the velocity at 300 so the player doesn't accelerate to infinity
if(FlxG.keys.pressed("LEFT") || FlxG.keys.pressed("RIGHT")){
if(player.velocity.x > 300)
player.velocity.x = 300;
else if(player.velocity.x < -300)
player.velocity.x = -300;
}

super.update();
}
}

4
help / Re: Flixel-GDX PreLoader
« on: Mon, Sep 21, 2015 »
I actually figured it out, I just ended up using the LibGDX AssetManager instead of FlxAssetManager. Thanks again!

5
help / Re: Flixel-GDX PreLoader
« on: Mon, Sep 21, 2015 »
I've implemented that preloader in the past in a standard LibGDX project. I'm just having a bit of trouble understanding FlxAssetManager compared to the LibGDX AssetManager. I'm trying to replicate the percentage and finished loading logic with Flixel, but it doesn't seem like FlxAssetManager has the getPercentage() or update() methods used in the original. Is there something I'm missing?

What it looks like with LibGDX:
Code: [Select]
if (game.assetManager.update()) { // Load some, will return true if done
// loading
game.setScreen(new MenuScreen(game));
}

// Interpolate the percentage to make it more smooth
percent = Interpolation.linear.apply(percent, game.assetManager.getProgress(), 0.1f);

Also, thanks for always being on top of the forums your answers have always been very helpful. :)

6
help / Flixel-GDX PreLoader
« on: Sun, Sep 20, 2015 »
Are there any examples anywhere of a FlxPreloader implementation in Flixel-GDX? Not sure if it's even possible, I've been searching for a bit and coming up empty-handed. If it's not possible, does anyone have any suggested methods for preloading with Flixel-GDX?

Thanks!

7
help / Re: Flixel-GDX: Help with Box2D Collision
« on: Wed, Jan 14, 2015 »
I have read through the docs and I've tried building some samples, but I think I need to spend more time playing with box2d on a smaller scale in order to understand it. On another note I realized the other day that i was so focused on flixel that i forgot about lib-gdx, lib-gdx has polygon support and I'm thinking I might try to do it that way since I have a better grasp on it.

8
help / Re: Flixel-GDX: Help with Box2D Collision
« on: Sun, Jan 11, 2015 »
One thing, don't mix Quadtree (flixel's default collision system) with Box2D. Collision and motions needs to be done with one algorithm.

So, if I understand you correctly you're saying I should use Box2D for both sprite motion and collision right? Right now I'm using Flixel for motion with Box2D collision and was beginning to suspect that was part of my issue. I have been doing quite a bit of Googling about Box2D, but I'm new to it and there are some things I feel like I haven't quite grasped yet. Thanks for your help!

9
help / Flixel-GDX: Help with Box2D Collision
« on: Sat, Jan 10, 2015 »
Hi All,

I am working on my first original game prototype and I'm struggling a bit. Please feel free to tell me if I'm doing something stupid, I'm here to learn as much as I can and I've only got Google to guide me.

Background info: The game is a 2d, top-down game that involves moving around the screen and avoiding enemies. When I started the game I was using Flixel-GDX on its own and everything was going well, but then I decided that I wanted the enemies to have a field of vision that covers only a certain area in front of them which will trigger the logic that makes them follow the player. After looking into it a bit I thought it would be a good idea to create the field of vision as a polygon and test for a collision with the player. I figured out that I could not create polygons in Flixel, so I set up Box2D which allows for the creation of many types of shapes. After getting that set up, I converted all of my sprites to B2DFlxSprite and now I'm having issues and any help would be awesome.

My Issue:

When I use Flixel collision, I have to cast the B2DFlxSprite to a FlxObject and it's adding 11 pixels to the screen position. This is problematic because I have a sprite which is removed from the screen and later re-drawn and it gets offset by 11px.

When I use Box2d collision, nothing happens. I played with the collision examples a bit and read about how collision is handled in Box2d and I was able to get a working demo running with dragable objects. I think the issue might have something to do with the fact that I'm setting the velocity of my sprites with the FlxSprite functions, but I'm not sure.

Can anyone provide some insight on this? I feel like there's something important that I'm just not getting.
Thanks!

-Dan

10
help / Re: Help! Using Flixel-GDX + Flixel-GDX-Box2D
« on: Wed, Dec 3, 2014 »
Perfect, downloading the box2d jars from the nightly fixed my issue, thanks! Also, thanks for writing an awesome Flixel port!

-Dan

11
help / Re: Help! Using Flixel-GDX + Flixel-GDX-Box2D
« on: Tue, Dec 2, 2014 »
Hey Wing,

Thanks for the quick reply. I'm not able to get the examples running either, same issue actually. It's good to know the code should be correct. I built flixel-gdx-box2d as a jar and included it as a library in my project and I'm wondering if maybe something went wrong during that process. I'll see what I can figure out.

Thanks!
-Dan

12
help / Help! Using Flixel-GDX + Flixel-GDX-Box2D
« on: Sun, Nov 30, 2014 »
Hey Folks,

I'm a new poster to the forum, but I've been using Flixel for a while and I made the switch to Wing Eraser's awesome Flixel-GDX port recently when I discovered it. I've been working on a game and I realized recently that I need to use box2d. I was hoping to get Box2d going using the box2d port located here: https://github.com/flixel-gdx/flixel-gdx-box2d

Unfortunately, there is not a whole lot of documentation for that specific box2d port and I am a bit stuck. I've written a very simple test to render a box on the screen but I have not been able to get it running.

I've been getting this error message:
Code: [Select]
java.lang.NoSuchMethodError: com.badlogic.gdx.graphics.g2d.Sprite.draw(Lcom/badlogic/gdx/graphics/g2d/SpriteBatch;)V
at org.flxbox2d.collision.shapes.B2FlxShape.draw(B2FlxShape.java:518)

I tracked the issue down to the line where the box is added to the world. But I can't figure out why it's failing. When I comment out add(box.create()); The application will build and run, but the box is (obviously) not created. This error occurs when adding any B2FlxShape objects but when I add a normal FlxSprite everything works as expected. Any ideas?

Here's the code that I've got written so far:
Code: [Select]
import org.flixel.FlxG;
import org.flixel.FlxSprite;
import org.flxbox2d.B2FlxB;
import org.flxbox2d.B2FlxState;
import org.flxbox2d.collision.shapes.B2FlxBox;

import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
import com.badlogic.gdx.physics.box2d.World;

/**
 * A parent class for testing.
 *
 * @author Ka Wing Chin
 */
public class PlayState extends B2FlxState{

private World world;

@Override
public void create(){
super.create();

FlxG.mouse.show();

B2FlxB.world.setWarmStarting(true);
B2FlxB.setGravity(0, 9.81f);
FlxG.visualDebug = true;

B2FlxBox box = new B2FlxBox(50, 50, 50, 50);
box.setRestitution(.3f);
    box.setFriction(.2f);
    box.setDensity(.8f);
    box.setDraggable(true);
   
    add(box.create());
}

@Override
public void update(){
super.update();

}

@Override
public void destroy(){
super.destroy();
}
}

Any help is much appreciated. Thanks!
-Dan

Pages: [1]