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