I give up @flashpunk entities, need help converting it to work with MovieClips.. XML parsing and collision detection [SOLVED, I feel stupid now]


(John Andersson) #1

Hey. After so much frustration, I decided to stop using Flashpunk for entities. I myself know Flash’s MovieClips well enough to fix all of my current problem with entities… Paperdolling is only one of those problems.

I do like flashpunk, but the whole graphical part seems so complex to me. To have to draw spritemaps and then display them instead of just having a movieclip with different frames seems very… unnecessary to me.

One thing I do like about flashpunk is the collision functions, they are really good.

But I’m thinking that I can do everything in flashpunk except for entities. I will use movieclips instead.

So the first problem is this:

I made an XML parser in flashpunk to load levels, and from there, I added the hero. I need to make it work with movieclips instead!

public class Level extends Entity
{
	private var _tiles:Tilemap;
	private var _ground:Grid;
	private var _wall:Grid;
	public var LevelData:XML;
	
	public static var heroSpawnPoint:Point;
	
	public function Level(xml:Class)
	{
		_tiles = new Tilemap(Assets.SPRITE_TILESET, 9840, 1080, 120, 120);
		graphic = _tiles;
		layer = 2;
		_ground = new Grid(9840, 1080, 120, 120, 0, 0);
		mask = _ground;
		type = "ground";
		loadLevel(xml);

	}

	private function loadLevel(xml:Class):void 
	{ 
		var rawData:ByteArray = new xml; 
		var dataString:String = rawData.readUTFBytes(rawData.length); 
		LevelData = new XML(dataString);

		var dataElement:XML;
	
		var dataListSpawn:XMLList;

		dataListSpawn = LevelData.Entities.Spawn;
		
		for each(dataElement in dataListSpawn)
		{
			FP.world.add(new Hero(new Point(int(dataElement.@x), int(dataElement.@y))));
			heroSpawnPoint = new Point(int(dataElement.@x), int(dataElement.@y))
		}
	}
}

I tried changing

FP.world.add

to

addChild

to make it work with movieclips (since I changed the hero from “extends Entities” to “extends MovieClip” But it doesn’t work, so I’m very confused on how to make it work… So how can I add movieclips through that xml code?

Also, I’m gonna have big problems with collision detection. Previously, I used something like

var weaponCollideSmall:Weapons = collide("weapon", x, y) as smallWeapons;

To detect collisions, but obviously it won’t work now… Since movielips don’t use “type = “blabla””

Any ideas on how to make this work as smooth as possible?

ANy other ideas? Thanks


(Bora Kasap) #2

I think you’re going to make things much more complicated step by step. I’ve started to AS3 Coding first time with Flashpunk and i wasn’t have any knowledge without a little javascript and as2 when i start. And, i said, “Oh my god!!! Why the hell am i not used a game library before!!!” I’m not professional of course, but Flashpunk make me feel like a professional. I feel free with FP.

I think you’re not succeed because of your old knowledge about AS3 what i wasn’t have when i started to FP.

So, why don’t you try to forget everything about AS3 and try to make everything by Flashpunk’s ways, and try to solve your problems “with Flashpunk support”

All that your collision problems make me feel like, “you’re missing some really ‘basic rules of flashpunk’”, so, i think, you’re going to solve everything and say “Oh Yes!” if you reset your AS3 knowledge and follow Flashpunk Tutorials.


(John Andersson) #3

I guess you’re right. Thanks, I’ll keep on trying!!

That was easy, hehe


(Ultima2876) #4

FlashPunk takes a much more traditional approach to game development. It’ll serve you well to learn how it works, because it is way closer to how games are ‘really’ made; Flash is an animation tool and the way stuff is handled in that is quite different to how you’d often make games in other game development scenarios (eg C++, Unity etc). If you’re serious about game development you’d be better learning the ‘FlashPunk’ way.

In addition to that, MovieClips are SLOOOOOOW - especially on mobile. And mobile is where our industry is going, and fast.


(John Andersson) #5

Thanks, you guys have changed my mind. I was just too lazy, and I gave up for a short while. But now I’m back at it again!

WOO! Goo flashpunk!


(Jacob Albano) #6

This isn’t entirely relevant any more, but I’m going to reply with the comment I planned to make when I saw your first post during work today:

If you’re going to give up on Flashpunk, go for it. It might be the best fit for your workflow, and any choice that leads to more time being productive and less time being frustrated is a good one.

However…

If you do move back to Flash CS, this forum really isn’t the right venue for you to come to for help. We’re here to help people use Flashpunk, not as a general-purpose Flash board.

I’m not criticizing you for leaving, but coming onto the Flashpunk website and asking for help on how to use a different framework is like driving your new Ford back to the dealership and asking them to help you pick out a new Chevy.