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

Add-ons by Murii #71

Open
WingEraser opened this issue May 30, 2014 · 3 comments
Open

Add-ons by Murii #71

WingEraser opened this issue May 30, 2014 · 3 comments

Comments

@WingEraser
Copy link
Member

Hi guys,

A user tweeted me about add-ons and requests. He put the source at dropbox and he also made two videos which he shows examples and explains requests. The spare you guys time, I’ll put the summary here. URL: https://t.co/HJJ750ikqj

When he says "you", he actually means me. His video message was targeted to me.

Video #1

Slopes 45 degrees

He extended FlxTilemap and rewrote some parts of the overlap functions. It only works on 45 degrees, but it shouldn’t be too hard to support other degrees as well. This could be very handy if you want to stay at QuadTree algorithm.
I have plans to use Ninja algorithm from Phaser which is tiny and got a lot of different collisions possibility.
URL: https://github.com/photonstorm/phaser/tree/master/src/physics/ninja

FlxU WrapAngle

When an object keeps spinning the angle keeps increasing. With this method you can reset to the correct angle with a number between -180 and +180. I’ve use this in Box2D B2FlxSprite before.
The angle in FlxSprite won’t reset if you keep it rotated, it could be used in here.

FlxU AngleLimit

Don’t let the object rotate to the min or max degree.

FlxU MakeRandom

Generate a random int between min and max. It uses Random from Java API.
A dice makeRandom(1, 6).
This is actually the same as (int)(6.0*FlxG.random() + 1.0). We could use his method, but without the Random class.

FlxText TypeWriterEffect

It shows a char one by one depending on the speed you’ve set. This is very common in games.

Request - FlxGroup with type

Now we got FlxGroup::members array that holds FlxBasic. You need to cast every object into your object. Change this into:

FlxGroup<T extends FlxBasic> extends FlxBasic
members<T extends FlxBasic>

new FlxGroup<FlxBasic>(); // default
new FlxGroup<EnemyAbstract>();
group.getFirstAlive().attack(); // an enemy method without casting

A lot needs to be changed to get things back working again. I haven’t taken a look how to deal with reflection part though.

Request Spritesheet

I’ve relisted the request twice and still I have no clue what he is saying.

Video #2

This part is not relevant for the most of you. It’s about Tiled + Box2D support. He made a lot of classes to make this to work which wasn’t needed if he had used the latest version of FlxBox2D. The reason why he worked on Tiled + Box2D is to support slopes, but now he figured this out with QuadTree this is not needed.

But I’m doing him a fever to answer all his problems, because he made a video for me.

Follow and deadzone

This works if you run the example with the Cart. It will follow the object.

SpriteCache

Render sprites that are only static, which means no rotation, coloring, skewing, etc. This improves performance. Could be handy only if the benchmark says it’s worth it.

Lines from Tiled and convert to Box2D

If you know the coordinates then you can easily convert this to a box2d object without writing addition classes. Even creating slopes would be easy.

Other editors.

A friend of Emanuel uses RubeLoader to create levels in Box2D, which is better suited than Tiled. There is another editor for Windows only, but I forgot the name.

Sorry pal, I won’t use your TiFlx classes. You should have use the latest version.


What do you guys think?

@ghost
Copy link

ghost commented May 30, 2014

Lines from Tiled can be converted to FlxSprites as well! The Request Spritesheet refers to the possibility of using animations both from column and rows like :
scb_p1enemies
If you have any new classes in mind that you want to add,give me a message and i`ll try to implement them!

@WingEraser
Copy link
Member Author

Let's pick the Stance, Walk and Jump animation as one spritesheet. This means the spritesheet looks like this:

Stance 0 1 2 3 4
Walk   5 6 7 8 9
Jump   10 11 12 13 14 (13 and 14 are empty)

Let's add another row Shoot, which only contains 2 animation
Shoot 15, 16, 17, 18, 19

new int[]{15, 16} is your int array.

Isn't this what you're asking, if so this is already implemented since the beginning :)

@ghost
Copy link

ghost commented May 30, 2014

:O,Omg it is!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant