Flash How to embed and display a sprite using flixel


The title says it simply.... I know how to do it when you extend
Sprite like so:
class="bbcode_description">Code:
class="bbcode_code">[Embed(source = '../lib/imgname.png')] />private var layer0Class:Class;
private var layer0:Bitmap = new
layer0Class();
addChild(layer0);
But how can you do
this using flixel?
ive been working on a as3 project using flex and fcs3 for a few months
now and have had no problems. now im trying to get a new project
started using flex and fcs3 but now i get this errror telling me that
import flash.display.Sprite (1046:type not found). how could this be?
ive tried running my old project and it still works.
Development Tools & Services
cannot convert flash.display::Sprite@39394a9 to
flash.display.MovieClip.
here is sample code
class="bbcode_container"> class="bbcode_description">Code:
var
enemyArray:Array = new Array();
var mySprite:Sprite; />mySprite = new Sprite();
addChild(mySprite);
var
myEnemy:Enemy;
myEnemy = new Enemy(); />mySprite.addChild(myEnemy);
enemyArray.push(myEnemy); />removeEnemy(e:Enemy)
{
  for(var i in enemyArray) />  {
      if(enemyArray[i] == e) />      {
       
enemyArray.splice(1,i);
   
Development Tools & Services
Hello All,
I have a brick class where I have created a rectangle
using flash.display.graphics.
I am using this brick class to
create a grid of 10 X 10 in another class called grid using new
brick() in a for loop.
I have another class called ball where I
have created a circle with flash.display.graphics.
The problem is
that I want to remove / destroy individual bricks when the ball hits
the bricks on Event.ENTER_FRAME which is not happening.
the error
I get is shown only for the last brick that is created in a for
loop.
ArgumentError: Error #2025: The supplied DisplayObject must
be a child of the caller.
at flas
Development Tools & Services
The title says it simply.... I know how to do it when you extend
Sprite like so:
class="bbcode_description">Code:
class="bbcode_code">[Embed(source = '../lib/imgname.png')] />private var layer0Class:Class;
private var layer0:Bitmap = new
layer0Class();
addChild(layer0);
But how can you do
this using flixel?
Development Tools & Services

I am trying to make a scene that extends up off the screen for a
certain distance, and I want the camera to stay centered on the player
node. When the player reaches the top of the screen, I want the bottom
nodes to disappear below the screen bounds and the new off screen part
of the scene to become visible. Like Mario!



I create the scene size like this:



CGSize screenSize = CGSizeMake(skView.bounds.size.width,
skView.bounds.size.height + (skView.bounds.size.height/3));//+
(skView.bounds.size.height/3)
scene = [GameScene sceneWithSize:screenSize];


And then, add all of my nodes to a WorldNode as in href="http://stackoverflow.com/questions/23851265/moving-a-camera-in-spritekit">This
question.



I have modified it to be:



- (void)didSimulatePhysics
{
CGFloat margin = self.size.height/3;// previously defined

// make sure the cat's position is defined in scene coordinates
CGPoint catPosition = [self convertPoint:cat.position
fromNode:cat.parent];

if (catPosition.y > (self.size.height - margin))
{
CGPoint worldPosition = worldNode.position;
worldPosition.y -= catPosition.y - (self.size.height -
margin);
worldNode.position = worldPosition;
}
else if (catPosition.y < (self.size.height - margin))
{
CGFloat maxWorldHeight = self.size.height;
CGPoint worldPosition = worldNode.position;
// this keeps the cat on the margin line
if (worldPosition.y != worldStartPosition.y)
{
worldPosition.y += (self.size.height - margin) -
catPosition.y;
}
if (worldPosition.y > maxWorldHeight) // assume
maxWorldHeight is defined
{
worldPosition.y = maxWorldHeight;
}
worldNode.position = worldPosition;
}

}


Ok, I have it almost working. I can't seem to stop the world at the
top boarder of the scene, and the character does not fall when he
reaches below the margin, as in the world keeps following him down
past the worlds initial start point. How can I get the screen to only
move up and down if the character is above the margin, and then if the
character is below the margin, the screen does not move?

Web Development

Is it possible to display a child sprite behind a parent sprite
with Phaser? I'd like to draw a ring around my sprite by rendering a
filled green circle and sticking it behind the parent sprite. I know
I can use a group for this, but I want the parent sprite to be
affected by physics and don't know how to reconcile this with the
group usage.



Here is a jsfiddle of my issue: href="http://jsfiddle.net/omm0vvfv/"
rel="nofollow">http://jsfiddle.net/omm0vvfv/



<script
src='https://rawgit.com/photonstorm/phaser/master/build/phaser.js'></script>
<script>
var game = this.game = new Phaser.Game(800, 400, Phaser.AUTO, '', {
create: function() {
game.physics.startSystem(Phaser.Physics.ARCADE);

var main_sprite = game.add.sprite(200, 200, 'foo-sprite')
main_sprite.anchor.setTo(.5, .5)
game.physics.arcade.enable(main_sprite)
main_sprite.body.gravity.y = 30

var bmd = this.game.make.bitmapData(main_sprite.width * 2,
main_sprite.width * 2)
bmd.circle(bmd.width * .5, bmd.width * .5, main_sprite.width,
'#0000ff')
var ring_sprite = this.game.make.sprite(0, 0, bmd)
ring_sprite.anchor.setTo(.5, .5)

// I can get the ring behind the sprite like this, but it doesn't
stick.
var group = game.add.group()
group.add(ring_sprite)
group.add(main_sprite)
ring_sprite.x = main_sprite.x
ring_sprite.y = main_sprite.y

// If I do this it sticks, but I can't get it behind the sprite.
// main_sprite.addChild(ring_sprite)
}
})

</script>
Web Development

- Technology - Languages
+ Webmasters
+ Development
+ Development Tools
+ Internet
+ Mobile Programming
+ Linux
+ Unix
+ Apple
+ Ubuntu
+ Mobile & Tablets
+ Databases
+ Android
+ Network & Servers
+ Operating Systems
+ Coding
+ Design Software
+ Web Development
+ Game Development
+ Access
+ Excel
+ Web Design
+ Web Hosting
+ Web Site Reviews
+ Domain Name
+ Information Security
+ Software
+ Computers
+ Electronics
+ Hardware
+ Windows
+ PHP
+ ASP/ASP.Net
+ C/C++/C#
+ VB/VB.Net
+ JAVA
+ Javascript
+ Programming
Privacy Policy - Copyrights Notice - Feedback - Report Violation 2018 © BigHow