Author Topic: two problems with my code  (Read 979 times)

KunoNoOni

  • "Never tell me the odds"
  • Active Member
  • ***
  • Posts: 170
  • Karma: +0/-0
  • Code is Love
    • View Profile
two problems with my code
« on: Mon, Jan 2, 2012 »
So I was fooling around with emitters and ran into two problems...

1. my pixel.makeGraphic(2,2,0xFFFFFFFF); isn't showing up. getting flixel logos instead.

2. there is no collision even though I set the floor and the particles to solid.

here is the code.

Code: [Select]
package
{
import org.flixel.*;

public class PlayState extends FlxState
{
//Variables go here
private var emitter:FlxEmitter = new FlxEmitter(FlxG.width*0.5,50); //x and y of the emitter
private var floor:FlxSprite;
private var pixel:FlxParticle;

override public function create():void
{

floor = new FlxSprite(0,208);
floor.makeGraphic(320, 32, 0xffFF66FF);
floor.solid = true;
add(floor);
for (var i:int = 0; i < emitter.maxSize/2; i++) {
pixel = new FlxParticle();
pixel.makeGraphic(2,2,0xFFFFFFFF);
pixel.visible = false;
pixel.solid = true;
emitter.add(pixel);
}
emitter.gravity = 50;
emitter.bounce = 1;

add(emitter);
emitter.start(false,3,.1);
}

override public function update():void
{
super.update();
}
}
}




-KunoNoOni

bpercevic

  • Member
  • **
  • Posts: 87
  • Karma: +2/-0
    • View Profile
Re: two problems with my code
« Reply #1 on: Mon, Jan 2, 2012 »
FlxEmitter takes care of the particles itself.  The only reason you'd pass your own particles in is if it were a custom class.  So just do:
Code: [Select]
emitter.makeParticles(PNG of your particles...);
emitter.start(...);

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: two problems with my code
« Reply #2 on: Tue, Jan 3, 2012 »
Are you trying to emit 2x2 pixels?
blog, twitter, Check out my award winning game, Rot Gut:

KunoNoOni

  • "Never tell me the odds"
  • Active Member
  • ***
  • Posts: 170
  • Karma: +0/-0
  • Code is Love
    • View Profile
Re: two problems with my code
« Reply #3 on: Tue, Jan 3, 2012 »
yes I am trying to emit a 2x2 white particle. If you checkout the flixel features page you'll see the demo that TestSubject06 did, I kinda modeled my code after his. Just don't understand why I'm getting the two problems.


-KunoNoOni
« Last Edit: Wed, Jan 4, 2012 by KunoNoOni »