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 - bpercevic

Pages: 1 2 3 [4] 5
61
help / Re: Is this possible to do? (graphics question)
« on: Wed, May 25, 2011 »
no,

redThing.alpha = 0.75; //make it transparent
redThing.scrollFactor.x = 0.5; //make it scroll slower

62
help / Re: Is this possible to do? (graphics question)
« on: Wed, May 25, 2011 »
Change it's alpha and scrollFactor

63
help / Re: problems with loadMap ()
« on: Wed, May 25, 2011 »
Collide index is which tile range to collide. For example, collide index of 50 means that any tile 50 or above will be collidable.

Draw index is which tile range the engine actually starts to render. If you put 0 then all tiles are rendered, but if you put 10 then the tiles <10  will appear blank but >10 will render.

Starting index is something new that I don't completely understand how to use, but it comes in handy when the data for your tilemap was made in an editor like Tiled. The very first index on a tileset is usually 0 but Tiled, for example, treats that as a 1 and when you use data created by Tiled for your map then your tiles will all be offset by 1. So by setting starting index to 1 it can fix that offset.

Hope this helps.

64
help / Re: Cameras and collision problems
« on: Sun, May 22, 2011 »
you just need to add .follow() to one of your tilemap layers.

ex:
Code: [Select]
floor:FlxTilemap = new FlxTilemap(...);

override public function create():void {
   ...
   floor.follow();
   add(floor);
}

65
help / Re: 2.5 TileMap collision issues :(
« on: Sat, May 7, 2011 »
beautiful, thank you deviantgeek.

66
help / 2.5 TileMap collision issues :(
« on: Sat, May 7, 2011 »
Okay so 2.5 is great, but doesn't really work for me like the previous version  :-\

The problem is that collision with my tilemap only works for the initial tilemap that was rendered on the screen.  the rest is just walkable and i dont know why. there's a label with the player's Y, at about 600 the collision breaks, <600 is okay, >600 not working.

here's my code:
http://pastie.org/1875221

and here's the swf:
http://www.swfcabin.com/open/1304781565


Any help is appreciated

67
help / Re: Velocity adjustment from core position
« on: Fri, Apr 8, 2011 »
im not sure how deep your understanding of private/public is, but if a var/function is private then it can only be accessed from within the same class/file that it's in.  but change that to public and any external class/file can access it.

can you post the whole file on pastie.org , itll be easier to help.

68
help / Re: Noob Camera Question
« on: Thu, Apr 7, 2011 »
easy fix :)

for starters, you're missing
Code: [Select]
super.create(); at the very bottom of your create override.

and then right before super.create(); put this:
Code: [Select]
FlxG.follow(_player);

but in order to follow the player, you need to add it, you add it via a reference instead of just a random instance.  so do this:
Code: [Select]
add(_player);

instead of:
Code: [Select]
add( new Player(...) );

69
help / Re: Velocity adjustment from core position
« on: Wed, Apr 6, 2011 »
One thing I'd change about that code from Rybar:
Code: [Select]
Math.floor(Enemy1.y)

I've found that using the actual value of Y to compare to another Y doesn't work since it'll never be that actual Y that you're looking for because of the massive amounts of decimal places that it calculates to.

70
help / Re: An inventory
« on: Sat, Mar 12, 2011 »
if your class isn't extending anything then super() isnt necessary.  super() just calls the constructor from the base class, so no extension means you have no base class.

i'm not sure what you mean by a list of item classes, do you mean an array that holds all the items?

71
check if your powerups group is added to the stage in the right order, aka not covered by a backdrop or anything?

72
timescale is too complicated.  you need a paused Boolean and you need to wrap your update function like this:
Code: [Select]
public function update():void {
   if( !paused ) {
      //do regular stuff
      // if press P then paused=true
      super.update();
   } else {
      // here you can do your dialogs and stuff
      // also if press P then pause=false so you can return to game
   }
}

73
help / Re: Newb question: Help with my FlxButton
« on: Sun, Nov 21, 2010 »
not really sure what could be causing it to not show up but just for future references, you dont have to create a var for the callback function. do it like this
Code: [Select]
button = new FlxButton(Width, Height, function_name);

it knows to call function_name.  also, sometimes objects i create refuse to show up so when i add an update for them they do show up but at twice the normal speed, still havent figured out how to fix that.  but you could try adding char1.update(); somewhere in your update function.  hope that helps

74
help / Re: createGraphics
« on: Sun, Nov 21, 2010 »
maybe you should just do
Code: [Select]
cube.createGraphic(20, 40, 0xffff0000);
also, it looks like youre missing the first pair of f's where you call beginFill.  it should be 0xffFF0000.

hope that helps

75
help / Re: Preventing player from running off the level
« on: Thu, Nov 18, 2010 »
the way i do it is by colliding the player with the map.  my worlds are made of 3 layers, background, midground, and foreground.  background and foreground are not collidable with the player, but midground is.  

i draw my grass on the bg, my buildings and trees on mg, and clouds on fg.  and to bind the player to the level i just make sure that i have a border on my midground layer.

example, in my midground the 1 tile is collidable so it creates a boundary
Code: [Select]
1,1,1,1,1,1,
1,0,0,0,0,1,
1,0,0,0,0,1,
1,0,0,0,0,1,
1,0,0,0,0,1,
1,1,1,1,1,1

and my camera is bounded to the level anyway so it stops at the edge along with the player.

heres the simple code:
Code: [Select]
public function update_camera():void {
FlxG.follow(p);
FlxG.followBounds(0, 0, mapMG.width, mapMG.height);
mapMG.collide(p);
}

76
help / Re: collisions and overlaps [SOLVED]
« on: Wed, Nov 17, 2010 »
i dont understand why or how.  but this is what i had in my level update function:
Code: [Select]
FlxU.collide(p, enemies);
FlxU.collide(enemies, enemies);

i erased that code and rewrote it, letter for letter, and now collision works like a charm!

77
help / Re: collisions and overlaps
« on: Wed, Nov 17, 2010 »
Also how are you moving your enemies? I'm pretty sure modifying their x/y values directly ignores collision. Move them with velocity and they should collide just fine (it does this in the build of Flixel I'm using at the moment anyway!)

that has got to be it.  here's how my enemies move:
Code: [Select]
private function seek(speed:Number, distance:Number, target:FlxObject):void {
var dx:Number = target.x - this.x;
var dy:Number = target.y - this.y;
var aRadians:Number = Math.atan2(dy,dx);
var aDegrees:Number = 360*(aRadians/(2*Math.PI));
//pythagorean theorem to find distance c
var b2:Number = Math.pow(dx, 2);
var a2:Number = Math.pow(dy, 2);
var c:Number = Math.pow(a2+b2, 1/2);

if( c <= distance ) {
dx = Math.round(target.x - this.x);
dy = Math.round(target.y - this.y);

if( dx<0 && Math.abs(dy)<=Math.abs(dx) ){
if( Math.abs(dx)>speed) { this.x -= speed; }
}
else if( dx>0 && Math.abs(dy)<=Math.abs(dx) ){
if( Math.abs(dx)>speed) { this.x += speed; }
}

if( dy<0 && Math.abs(dx)<=Math.abs(dy) ){
if( Math.abs(dx)>speed) { this.y -= speed; }
}
else if( dy>0 && Math.abs(dx)<=Math.abs(dy) ){
if( Math.abs(dx)>speed) { this.y += speed; }
}
}
}
im just changing the coordinates to make it move.  however i just tried replacing this.x/this.y with velocity.x/y and they still overlap and ignore collision detection

i also do update world bounds as such:
Code: [Select]
FlxG.follow(p);
FlxG.followLerp = 0;
FlxG.followBounds(0,0,mapMainground.width,mapMainground.height);



78
help / [SOLVED] collisions and overlaps
« on: Tue, Nov 16, 2010 »
demo here:   x is melee, arrows move
http://megaswf.com/serve/73028/

im having difficulty with collisions and overlaps.  ive searched the forum inside and out but am unable to find a suitable solution.  

ive tried each these in my update but no luck
Code: [Select]
FlxU.solveXCollision(enemies, enemies);
FlxU.solveYCollision(enemies, enemies);

for each( enemy in enemies) {
enemy.collide(enemy);
}

i even added fixed=true and solid=true to my NPC and that didn't help.  for some reason enemies just go through each other no matter what.

enemies is just my group that holds all the enemies, each time an NPC is created i call enemies.add(npc)

a melee attack on individual enemies works, because i recursively call npc.hurt(1) and it executes that properly.  so that eliminated my first thought that i was possibly adding the enemies incorrectly.


79
help / melee methods for topdown games
« on: Sun, Oct 10, 2010 »
im searching for different ways one can implement melee attacks for a topdown shooter.  here is my method which isn't really working for me that well.  basically i create a shape in front of the player for a split second and check overlap between the npc and the shape, if overlaps then destroy the shape and health-- on the npc.  however it seems to not be killing the shape and although it disappears after a split second it continues to drain the health of the npc and it dies within seconds.

in my base Level class i have lots of functions for creating and managing objects in the game.  here is a function for the attack:
Code: [Select]
// attacks is a FlxGroup
public function createAttack(X:Number=0, Y:Number=0, W:Number=1, H:Number=1, C:uint=0xFF597137):Shape
{
var attackToAdd:Shape = new Shape(X,Y,W,H,C);
attacks.add(attackToAdd);
return attackToAdd;
}

here is the function in action:
Code: [Select]
// this is just one of the times its called,
// the location of the melee is determined by the players velocity
// i wont show all of them since they are all the same for each direction
if(FlxG.keys.justPressed("X")) {
if(p.velocity.x > 0) {
melee = createAttack(p.x+6, p.y, 10, 3);
meleeTimer = 1.1;
}

// here is where i think the problem is
meleeTimer -= FlxG.elapsed;
if(meleeTimer > 0) {
if(meleeTimer <= 1) {
//FlxG.flash.start();
//attacks.kill();
//melee.kill();
                //melee.destroy();
attacks.destroy();
}
}

i think that the shape created as the melee attack isn't getting destroyed, and it floats on top of the enemy and drains the health completely in an instant.  i tried melee.kill()/destroy() and killing the entire group.  i dont really understand the difference between kill() and destroy(), but either way neither of those are working in this case.

i would greatly appreciate any help, even if it is an entirely different method for melee attacks.  this is my first flixel project, well first game project all-together, so i apologize for any newbie mistakes. thanks!

80
help / Re: building issues
« on: Sun, Oct 10, 2010 »
i tried to clean the project but it did not wipe the bin-debug folder, all the files were there untouched.  i also tried changing the launch settings, by default it is set to launch an html wrapper with the swf but i changed it to launch the swf instead but the problem was that the swf it was launching was the one that it wouldnt write over.

but i solved the issue, i downloaded adobe flash builder and just created a new project and transferred my files over and now it builds fine.  flex builder however still doesn't work.

i appreciate your help anyway, thanks!

Pages: 1 2 3 [4] 5