Giter Site home page Giter Site logo

citrus-engine's People

Contributors

alamboley avatar gsynuh avatar ivanchen008 avatar mark-lacroix avatar smurfatron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

citrus-engine's Issues

gleed2d starling texture atlas

I know everyone hates on gleed2d, but I think there should be an official citrus engine, gleed2d, straling textureatlas for objectmaker2d. Right now I have written my own code for it, but seems like something others will want later. Especially if CE ever makes it to PSN or XBLA.

engine can't compile successfully

描述 资源 路径 位置 类型
class Box2DComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 beginContactCallEnabled Box2DComponent.as /Citrus-Engine/src/citrus/system/components/box2d 第 26 行 Flex 问题
class Box2DComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 beginContactCallEnabled Box2DComponent.as /Citrus-Engine/src/citrus/system/components/box2d 第 26 行 Flex 问题
class Box2DComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 endContactCallEnabled Box2DComponent.as /Citrus-Engine/src/citrus/system/components/box2d 第 26 行 Flex 问题
class Box2DComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 endContactCallEnabled Box2DComponent.as /Citrus-Engine/src/citrus/system/components/box2d 第 26 行 Flex 问题
class Box2DComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 postContactCallEnabled Box2DComponent.as /Citrus-Engine/src/citrus/system/components/box2d 第 26 行 Flex 问题
class Box2DComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 postContactCallEnabled Box2DComponent.as /Citrus-Engine/src/citrus/system/components/box2d 第 26 行 Flex 问题
class Box2DComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 preContactCallEnabled Box2DComponent.as /Citrus-Engine/src/citrus/system/components/box2d 第 26 行 Flex 问题
class Box2DComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 preContactCallEnabled Box2DComponent.as /Citrus-Engine/src/citrus/system/components/box2d 第 26 行 Flex 问题
class HeroPhysicsComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 beginContactCallEnabled HeroPhysicsComponent.as /Citrus-Engine/src/citrus/system/components/box2d/hero 第 10 行 Flex 问题
class HeroPhysicsComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 beginContactCallEnabled HeroPhysicsComponent.as /Citrus-Engine/src/citrus/system/components/box2d/hero 第 10 行 Flex 问题
class HeroPhysicsComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 endContactCallEnabled HeroPhysicsComponent.as /Citrus-Engine/src/citrus/system/components/box2d/hero 第 10 行 Flex 问题
class HeroPhysicsComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 endContactCallEnabled HeroPhysicsComponent.as /Citrus-Engine/src/citrus/system/components/box2d/hero 第 10 行 Flex 问题
class HeroPhysicsComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 postContactCallEnabled HeroPhysicsComponent.as /Citrus-Engine/src/citrus/system/components/box2d/hero 第 10 行 Flex 问题
class HeroPhysicsComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 postContactCallEnabled HeroPhysicsComponent.as /Citrus-Engine/src/citrus/system/components/box2d/hero 第 10 行 Flex 问题
class HeroPhysicsComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 preContactCallEnabled HeroPhysicsComponent.as /Citrus-Engine/src/citrus/system/components/box2d/hero 第 10 行 Flex 问题
class HeroPhysicsComponent 未实现 interface IBox2DPhysicsObject 中的 interface 方法 preContactCallEnabled HeroPhysicsComponent.as /Citrus-Engine/src/citrus/system/components/box2d/hero 第 10 行 Flex 问题

The StarlingState destroy() method triggers an error (Error #1009) .

Hi!

I never reported any 'bugs' before so sorry for the wording of the issue here.

I tried the new citrus engine out yesterday, using the CE master source code and nape + starling's .swc (my personal favorite.) I went for the source code here, to trace the problem I'm having because the .swc files don't allow me to see the source code in my editor.

I decided to look for some kind of state switching method in the StarlingCitrusEngine class that could help me switch to a new state during a game. couldn't find it (not read the whole doc yet)

So in the process of having my own, I first tried the first sensible thing to do, destroying a state...

public class Main extends StarlingCitrusEngine
{
public function Main():void
{
setUpStarling(true, 0);
state = new Statetest();
state.destroy();
}
}

state.destroy(); triggers Error #1009 (Cannot access a property or method of a null object reference.)
the property in question apparently is StarlingState's view being apparently null when destroy() is called.

Statetest here is composed of only nape objects (Platform, Hero, Coin.) nothing fancy, it's basically the gotoandlearn tutorial. It works fine when I don't call the destroy function.

At first I thought it was because I didn't set any "view" element up, there were no graphics, but i set up the hero.view to be a little png file, which worked fine, but still the destroy method didn't work.

I hope this is not a silly error on my side, I never report bugs and always try to google my problems but I felt like I had no choice here.

I would like to take this opportunity to thank you Aymeric, for your interesting blog articles and your work on this engine which you decided to release open source.

Components.fla and Hero's dynamicFriction

Charlie, on the forums,
(http://forum.starling-framework.org/topic/need-help-to-convert-ce2-game-to-new-engine-napestarlingce#post-21544)
reported that using Components.fla triggers a warning as Components have the dynamicFriction property... which obviously gets set with the setParams() function in CitrusObjects (or in ObjectMaker) ...
But dynamicFriction is not an available public var upon construction (at least that's what I feel the problem is) so the message :
"Warning: The parameter dynamicFriction does not exist on [object Hero]"
would always be traced when trying to set dynamicFriction through params. and specially when loading levels made from Components.fla .

(I'm not using the right terms nor I am explaining myself right, but surely when we try this["dynamicFriction"] = 10; in the parent of this class, then public function set dynamicFriction doesn't exist yet so the "super" is not aware of that property and throws an error right?)

Hero will not switch facing direction while in mid-air.

Hello.
Again, I had trouble for the title of this issue to be clear.
I finally got to play more with the code, Once I added a view to my hero, I noticed it wouldn't face the right direction while in mid air.
I wouldn't see this as an Issue, but it's not coherent with the fact that we can physically move the Hero around when we are not on the ground.

The 'problem' in question is on Nape, but apparently on box2D's Hero, and maybe on others. This must be a choice you made willingly.

The code related is the code handling the animation changes either in update() for the Nape Hero or updateAnimation() for the box2D Hero:

//Nape's Hero (~ line 252)

            if (_hurt)
            {
                _animation = "hurt";
            }
            else if (!_onGround)
            {
                _animation = "jump";
            }
            else if (_ducking)
            {
                //_animation = "duck";
            }
            else
            {
                //var walkingSpeed:Number = getWalkingSpeed();
                var walkingSpeed:Number = _body.velocity.x; // this won't work long term!
                if (walkingSpeed < -acceleration)
                {
                    _inverted = true;
                    _animation = "walk";
                }
                else if (walkingSpeed > acceleration)
                {
                    _inverted = false;
                    _animation = "walk";
                }
                else
                {
                    _animation = "idle";
                }
            }

My suggestion here would of course to add something like

                var walkingSpeed:Number = _body.velocity.x;
                if (walkingSpeed ‹ -acceleration)
                {
                    _inverted = true;
                }else if (walkingSpeed › acceleration){
                    _inverted = false;
                }

inside the

else if (!_onGround)

condition.

This means walkingSpeed would need to be moved around so that we don't declare it twice ...
Or it'd maybe be easier to change the conditionals sequence around, I don't know. I did check the box2D Hero to see if that wasn't just me/ just nape.

What are your thoughts on this?

View changed but animation doesn't update on the new view.

The problem is (using a dragon bones asset example) :

  • at first the object is created without a view specified (created by Flash Pro for example).
  • it plays the function set animation.
  • it isn't a armature at the moment so he won't played its animation.
  • we set up the dragon bones animation.
  • the function set animation won't go to dragon bones part since the animation hasn't changed.

To resume, the view has changed but not the animation so its animation isn't updated.

objects on moving platform "jump" if it changes direction to downward

it could be argued that this is perfectly physical behavior, however, if I leave the hero standing on the moving platform and go for my coffee, I do not expect it to be dead after a while because he moved to the edge and fell off.

could there be some kind of hack implemented that will change the inertia of all the bodies that contact moving platform when it changes direction?

Cameras

Leaving a quick note here so I can remember and people can react.

To prevent effects such as camera lagging when target is moving at high speeds, or camera stutter or any other weird artefacts... camera should be updated AFTER the state and the objects are updated because right now, camera is updated before objects are updated therefore is always one step behind what should appear on screen.

(a hack/fix consists of calling camera.update() at the end of a state's update. though this means doing twice the calculations.)

Box2d sensor weird bug

I've been using the sensor to load unload art assets. And I am using the onEndContact method for it. When the hero is actively touching the sensor though, they can continuously jump while in the air. If I use the onContact method this doesn't happen. I've since switched to Nape, and it does not have these issues.

I looked at the hero.as in the box2d section, but I don't see what would cause this issue at all.

ObjectMakers and checkpoints

I thought I'd start this discussion here since "Issues" is the place to discuss the code itself.
So I was wondering, if there is a game to which levels were created using flash pro, and inside this level would be collectable items such as coins maybe.
And your hero died at some point and you'd restart the level.
Now this may not make sense but maybe you'd want your already collected items to not appear anymore when the level gets restarted... This would make more sense if they were something else rather than coins.
I could see various ways of achieving that... but one possibility that would give easy access to such a feature would be to have ObjectMakers accept an array of object names that would refere to objects that shouldn't be created.
That way you could restart a level, telling ObjectMaker that the item "item1" shouldn't be re-created on this instance of the level, it would simply bypass the creation of it when processing the level data.

This in turn would benefit in creating a checkpoint system, as levels are not always supposed to be exactly the same. Of course in a checkpoint system, ultimately you would save your score, the position of your hero and ennemies and more properties, but what you wouldn't want to do, is create objects that you would kill instantly just to make it look like you are replaying the same level but in a saved state.

So that is the first Idea I had in mind, There are probably better approaches though, but this seemed fair enough to propose and get the discussion started... As I hope to get a checkpoint system possible , or at least possibly write a tutorial about how such a thing can be done - through the use of "game data" classes as well , which might need a solution for saving data without having to touch SharedObject directly.

Thanks for reading :)

Add a flag to StarlingArt/SpriteArt... to prevent update

When we're dealing with large background, or having many static elements (platform) it may consume cpu.

Now thanks to the updateCallEnabled flag, we can prevent the update method from the logic to run. I suggest to add one to StarlingArt, by default it will be turned to true (updateArtEnabled).

This way we can reduce all call for static elements.

Be careful, static elements are element which won't have any change. Meaning if I turned this updateArtEnabled to false, and I change the x position of my platform, the art position won't be updated.
So to be used carefully!

Possibly a bug

When calling
CitrusEngine.getInstance().state = new GameLevel();

Where GameLevel is the demo map Level

my game crashes on
StarlingView.as:103
which is
spriteArt.destroy();

If dismissAll, after warning, it only unloads the citrussprites. And leaves all of the starling buttons, images, and quads.

After digging into it, I don't see any method for removing the buttons or quads.

I submitted this on the CE forums too as I was unsure if this was a bug or intended.

Loading displaylist Ui menus from external swf

This is something I'm using right now which is quite useful.

With feathers you don't get any wysiwyg editor, so using flash
So I have done my research and applied that research, what we could be having for milestone 3.1.5 or later is people can build their pause menus, home screen menus etc, in flash (inside MovieClips)

then you can load them up inside your game and display them.
you don't have to programatically do their layout.

I will not go into details if you don't think this is a good idea yet, but I can say that it works very well on my side.

though I can give hints of how my thing works :

In my document class (Main) I load a ui.swf file which contains all menus I'll be needing in its library.
I have a BaseUI class which I extend, if my class name is HomeScreen, then it will load the HomeScreen class from ui.swf , then I plug it as a child of the HomeScreen class inside my project so HomeScreen contains the ui visually, and I can do my logic in there.

what I realized I can do as well, is upon loading an external swf, you can change the loader's application domain to set it as the "current apllication domain" which means instead of loading a class and instantiating it there, you would theoretically be able to simply extend it as it would be part of the current application domain once loaded !!

This is great news as well to load graphics from level.swf as well for prototyping !!!!

Anyway those tricks are needed for CE, for flash pro to be even more of an editor rather than just a simple thing we loop through to get properties and params etc...

I'd be glad to show you my classes, if you think its a good idea and everything.
It can be optimized as well.

a visually complex ui would be more pleasent to edit with flash rather than feathers.

[request] alpha in APhysicsEngine

Right now I have to do

var physics : Box2D = new Box2D("box2d"); 
physics.visible = true; 
add(physics); 
Starling.current.nativeStage.getChildAt(Starling.current.nativeStage.numChildren - 1).alpha = 0.5;

to see actual art beneath debug view. which is wtf, right?

Jump bug /w Nape

If your Hero is against the wall and it can reach the ceiling by jumping.
Now if you hold your movement key towards the wall, jump and then hold both buttons down, the Hero will hang on the wall as long as you release the buttons.

http://youtu.be/dUjNAC3WKD4

I haven't tried with Box2D version, but at least with Nape it occurs.

Multiple swc target

Those are not very usefull, you should keep only the full .swc, and in the ant task for building your game, use -library-path instead of -include-libraries, the resulting swf will only pull from the swc what is really needed. This will save you some work when doing a release, and result in the lightest posible swf.

As a benchmark, the tipical hello world tutorial, from the old sites videos, is only 81,7 ko

https://dl.dropbox.com/u/725020/citrus/Platformer.swf <-- you can check it here.

Changing Starling viewport messes up nape physics

Screen Shot 2013-01-24 at 12 04 46 AM
changing starling stage width and height (exists in the mobile example)
messes up the syn between Nape physics and a Nape Object view.

_starling.stage.stageWidth = 320;
_starling.stage.stageHeight = 480;

then setting nape to visible, you can see that the body physics and the view of a NapePhysicsObject are off.

(Image attached).

AnimationSequence onAnimationComplete terminates the loop without reason.

See an example of a hero:

package game.characters
{
import citrus.objects.platformer.nape.Hero;
import citrus.view.starlingview.AnimationSequence;

import flash.display.Bitmap;
import flash.events.TimerEvent;
import flash.utils.Timer;

import starling.textures.Texture;
import starling.textures.TextureAtlas;

/**
 * @author Jonathan Reis
 */
public class HeroTest extends Hero {

    [Embed(source="/../assets/chars/Espantalho.xml", mimeType="application/octet-stream")]
    private var _heroConfig:Class;

    [Embed(source="/../assets/chars/Espantalho.png")]
    private var _heroPng:Class;

    private var _attackBoomTimer:Timer;
    private var _isAttacking:Boolean = false;

    public function HeroTest(name:String, params:Object = null) {
        super(name, params);

        var bitmap:Bitmap = new _heroPng();
        var texture:Texture = Texture.fromBitmap(bitmap);
        var xml:XML = XML(new _heroConfig());
        var sTextureAtlas:TextureAtlas = new TextureAtlas(texture, xml);

        view = new AnimationSequence(sTextureAtlas, ["attack", "die", "fall", "walk", "duck", "idle", "jump", "hurt"], "idle");

        x = 183;
        y = 74;

        acceleration = 40;
        jumpHeight = 50;
        maxVelocity = 120;
        dynamicFriction = 10;

        offsetY = 0;

        _attackBoomTimer = new Timer(200, 1);
        _attackBoomTimer.addEventListener(TimerEvent.TIMER, attackBoom);

    }

    private function attack():void
    {
        trace("attack() -> attackBoom() -> attackFinishedAnim()");

        _animation = "attack";
        updateAnimation();

        _controlsEnabled = false;

        if(view is AnimationSequence){
            (view as AnimationSequence).onAnimationComplete.addOnce(attackFinishedAnim);
        }

        _attackBoomTimer.delay = 100;
        _attackBoomTimer.start();
    }

    private function attackBoom(event:TimerEvent):void
    {
        trace("attackBoom() completed.");
        _attackBoomTimer.reset();
    }

    private function attackFinishedAnim(name:String):void
    {
        trace("attackFinishedAnim() completed.");
        _controlsEnabled = true;
        _isAttacking = false;
    }

    override public function update(timeDelta:Number):void {
        if (controlsEnabled)
        {
            if(!_isAttacking){
                _isAttacking = true;
                attack();
            }
        }
        updateAnimation();
    }
}

}

My Output in Console:

[SWF] Main.swf - 3,944,196 bytes after decompression
[Starling] Initialization complete.
[Starling] Display Driver: OpenGL
[SWF] Main.swf/[[DYNAMIC]]/1 - 243,392 bytes after decompression
[SWF] Monstro.swf - 21,891 bytes after decompression
attack() -> attackBoom() -> attackFinishedAnim()
attackBoom() completed.
attackFinishedAnim() completed.
attack() -> attackBoom() -> attackFinishedAnim()
attackBoom() completed.
attackFinishedAnim() completed.
attack() -> attackBoom() -> attackFinishedAnim()
[Unload SWF] Main.swf

In 10 minutes running should run millions of times, but performs only 2 or 3 times and stops.
Please excuse me if it is any error in my code.

Should we have integrate a tweening library by default?

People have their preferences etc, so I can see how people can disagree.
I just replied to something about camera shaking. If CE had an integrated tweening library, then it would be done straight away and we would have
camera.shake(time,intensity) for example.

because this means either "reinventing the wheel" and tweening with our own equations and delay calling to create the shake effect with one function call easily etc...
or grab something like TweenLite to handle tweening/delayed calls etc.
unfortunately though, TweenLite for example has its own enterframe listener which means pausing CitrusEngine won't pause it - even though if its integrated then you can actually make that happen easily by pausing each instances that are running.

anyway it's a question, I think if there's any kind of state transition to have, this would also help to know.

listening to input actions in the state update.

I have managed to successfully listen to actions with "isDoing" but not "justDid" in my state's update function...
Can you confirm this behavior?

cause : action doesn't stay in the action list long enough for us to get it through justDid.
possible solution : change when input is being updated in a single frame.

(I'll take a look ASAP.)

Hero graphic not moving correctly

In the following code when the hero reaches middle of the stage his graphic (Quad(40, 40, 0x00FF00)) doesn't go further horizontally. However it keeps in sync vertically. You can see that the Box2D's debug draw graphic of the hero goes beyond the middle of stage.

Code:

package
{
import com.citrusengine.core.StarlingState;
import com.citrusengine.datastructures.DoublyLinkedListNode;
import com.citrusengine.datastructures.PoolObject;
import com.citrusengine.math.MathVector;
import com.citrusengine.objects.platformer.box2d.Hero;
import com.citrusengine.objects.platformer.box2d.Platform;
import com.citrusengine.physics.box2d.Box2D;
import com.citrusengine.view.StarlingSpriteDebugArt;
import com.citrusengine.view.starlingview.StarlingPhysicsDebugView;

import flash.geom.Rectangle;

import starling.display.Quad;

public class GameState extends StarlingState
{
    private var _hero:Hero;

    private static var _poolPhysics:PoolObject;
    private static var _poolGraphic:PoolObject;

    public function GameState()
    {
        super();
    }

    override public function initialize():void
    {
        super.initialize();

        var physics:Box2D = new Box2D("Box2D");
        physics.visible = true;
        physics.gravity.y = 2;
        add(physics);

        _hero = new Hero("hero", {x:100, y:100, width:40, height:40, view:new Quad(40, 40, 0x00FF00)});
        add(_hero);

        view.setupCamera(_hero, new MathVector(stage.stageWidth / 2, stage.stageHeight / 2),
                new Rectangle(0, 0, Number.POSITIVE_INFINITY, 0), new MathVector(.25, .05));

        _poolPhysics = new PoolObject(Platform, 50, 5, true);
        _poolGraphic = new PoolObject(StarlingSpriteDebugArt, 50, 5, false);

        for (var i:int = 0; i < 10; i++)
        {
            var p:DoublyLinkedListNode = _poolPhysics.create({
                x:100 + 110 * i, y:400 + 10 * i,
                width:100, height:20,
                oneWay:true,
                view:new StarlingPhysicsDebugView()
            });
            addChild(p.data.view);
            addChild(_poolGraphic.create(p.data).data);
        }
    }
}
}

[proposal] Input action as events

Hello there,
I'd like to know if you think input could be working only with signals now - for more precision.

input would have an output signal on which we can connect any listener function :
An input controller would send a signal (exactly as it is doing now) to input when triggering on or off an action (or changing a continuous action).
As before, these will be kept in a list.
justDid, isDoing and hasDone would check on that list (again this doesn't change)
But there would be a output signal like so

_ce.input.output.add(_handleActions);

private function _handleActions(a:InputAction):void
{
if(a.name == "jump")
{
//do jump.
}
}

the Input.update() would dispatch output on every frame for actions that are continous, so on every "input frame" you would get a call to _handleActions as well to update action values that are changed.
The good thing is, some people like working with events, and in any case this is more precise than quantizing actions into frames.
The bad thing (but I'm not sure of it) is too many calls.
But to remedy that, maybe we can actually create a custom signal just to have special arguments to it when adding listeners such as :

_ce.input.output.add(_handleBeginActions,InputAction.BEGAN);
this second argument, would mean _handleBeginActions will only be triggered when action is of type InputAction.BEGAN .
(if signals can't handle an extra argument, I'm sure it's easily doable)

This also means we can have a fairly decent and precise "mouse input controller"
just to have the "touch screen" event and everything.

The problem is still that if we don't keep the current system, then justDid() will not reply if we Key_UP/Key_DOWN in the same frame - the current system makes sure that action stays long enough in the list for justDid to find it. so we can't go "signals only" unless there's a good reason to so the two systems must co-exist.

If that does sound good I will look into is asap, unless you can find any holes in my reasoning and I'd be more than happy to discuss it more to see if we figure out the pros and cons

VerifyError: Error #1014: Class citrus.core.starling::StarlingState could not be found.

package
{
import citrus.physics.box2d.Box2D;
import citrus.objects.platformer.box2d.Platform;
import citrus.core.starling.StarlingState;
import citrus.objects.platformer.box2d.Coin;
import citrus.objects.platformer.box2d.Hero;
import citrus.objects.platformer.box2d.Enemy;
import Box2D.Dynamics.Contacts.b2Contact;

public class StarlingDemoGameState extends StarlingState
{

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

}

This is a basic example from Lee Brimlow's video, adapt it to new SWC 3.1.2 . I can't get it to work although in SWC 3.0.0 with older paths was working just fine.

The error from Output is

VerifyError: Error #1014: Class citrus.core.starling::StarlingState could not be found.

ReferenceError: Error #1065: Variable Main is not defined.

A signal to know when View is instantiated.

I have no idea if this suggestion sounds good, or if its not already possible - I didn't take the time to look deeper , to me it doesn't seem like it exists.

The thing that led me to believe that this might be useful is the following scenario :

You have a class extending the AnimationSequence (this idea came from a discussion on the forums, about a very specific case so I'm going to simplify it) ... let's call that class Anim .
you give it to hero:Hero after its been constructed... or rather before its view is turned into real art, this means you won't be able to add a listener function to onAnimationComplete until you are sure that its view is instantiated.

So if you did

hero:Hero = new Hero("hero1",{view:Anim});

For example, you can't use it as it remains a Class until hero is added to the state and its view (which is a class for now) turned into an instance of an AnimationSequence which will then make the AnimationSequence.onAnimationComplete signal available ... but only then.

And so you can't plug into this signal in initialize() or anywhere else inside Hero
by casting (_view as AnimationSequence).onAnimationSequence.add(onAnimationIsOver)...

unless you do this in update() and made sure its done only once, but that's really ugly !

Of course, this problem doesn't occur when view is already an instance of an AnimationSequence.
you can add your code to the Hero's constructor , after the super, and have direct access to your AnimationSequence if it was assigned to the view property as an instance.

So, in some obscure, and other less obscure scenarios , this idea would let us do the following :

//in the HERO class

public function Hero(name,params) {
super(name,params);
onViewCreation.add(onViewCreated); // lets imagine this is the signal that would be dispatched when art is created
}

private function onViewCreated():void {
if(_view is AnimationSequence)
(_view as AnimationSequence).onAnimationComplete.add(onAnimationOver);
}

private function onAnimationOver():void {
//do something with the animation
}

In this case, we would make sure

  1. that if view is a class or a string we wouldn't have to "wait" for the Hero to be added on stage and write that code after "add(hero)" in the state code...
  2. that way Hero can fully know when its view is created and that can potentially take off some load of code off of the state...
  3. we also ensure that if whatever our _view is, in the end if its an AnimationSequence then we will plug the right listener in (imagine a scenario where you would dynamically switch views/animation.)

And I also believe there might be other reasons for this to be useful, The major one is that you keep coding your view/animation/sprite related stuff INSIDE your object when you need to do something upon instantiation - which would need to be done in the state otherwise.

Does it sound any good ? :)

[thoughts] Pausing the game, animated menu.

Using Jugglers etc, one may realize that it's hard to create a custom pause system , if your pause menu is rendered with starling !

the simple reason here is what Citrus Engine does by default on stage deactivation is stop starling.
therefore this needs to be overriden so that starling keeps running for the pause menu etc.
unfortunately now, objects behind or anything plugged into the default juggler (tweens or IAnimatable objects) are still being animated !

I would suggest that Citrus Engine would have 2 custom jugglers by default, that can be paused. AnimationSequence would plug into one of these and so when Citrus Engine pauses, this custom juggler would pause - the entire game would appear to be on pause - then the 2nd juggler would still be running for the pause menu (feathers or custom starling object)... or even for anything that you'd want to keep animating when the game is paused :

the idea is stopping starling altogether seems a bit too much specially for transitions/menu animations etc (cause if your pause menu is static then this remark is unrelevant of course).

for non starling states, then it's only a matter of having two enterframe listeners, one which will stop all updates, the other which will still run for ui or anything that shouldn't be affected by the pause.

overall, this means having two controllable but very basic "timelines" so customizing pause etc.. is no longer painful.

However, maybe this idea is wrong, how would you manage an animated pause menu when your game is paused for example?

Camera and scaleFactor

Camera bound work well when scaleFactor = 1

But the camera bound is wrong when scaleFactor >1

I mentioned this problem before, and didn't get fixed. Now I check the code and find the problem.

In ACitrusCamera.as Line:53

cameraLensWidth = ce.stage.stageWidth;
cameraLensHeight = ce.stage.stageHeight;

In my case:
ce.stage.stageHeight = 480 on iPhone 3GS
ce.stage.stageHeight = 800 on Google Nexus S
ce.stage.stageHeight = 960 on iPhone4

CE compute bound is like this:

if (-_viewRoot.y + cameraLensHeight >= bounds.bottom)
    _viewRoot.y = -bounds.bottom + cameraLensHeight;

But the StarlingState's stage.stageHeight always is 480, for starling compute stage size in point(320x480) , but rendering in pixel(640x960).

so the CE bound computing is wrong.

And I correct the problem by using a hacking way in my game state:

bound.height = bound.height - stage.stageHeight + CE.stage.stageHeight

That is not a normal way, you should fix that in CE. You ignore the starling's scaleFactor. You should include that, like this:

cameraLensWidth = StarlingState.stage.stageWidth;
...

or

cameraLensWidth = ce.stage.stageWidth / scaleFactor;
...

Changing jump behavior

By default, when pressing jump key and as soon as a direction key is pressed (even very quickly) it jumps very strongly in the direction.
This is undesirable, can this be modified?

tiled map parser's problem

I found sometimes the map layer order in my game is not as same as tiled map editor. Finally, I found the problem:

In citrus.utils.objectmakers
ObjectMakerStarling.as Line 58

for (var layer:String in tmx.layers) {
trace("ObjectMakerStarling layer:",layer); // added by blackgun for testing
...

trace result:

sometime log:

ObjectMakerStarling layer: L2
ObjectMakerStarling layer: L1

sometims log:

ObjectMakerStarling layer: L1
ObjectMakerStarling layer: L2

tmx.layers is an object but not an array, "for in" loop will Not get a fixed order, it will get a random order.

I think you should pack the layer data into an array

Improve physics performances by adding flags on collision call (begin, end, ongoing...) ?

Basically, Box2DContactListener does for each type of contact :

override public function BeginContact(contact:b2Contact):void {
    contact.GetFixtureA().GetBody().GetUserData().handleBeginContact(contact);
    contact.GetFixtureB().GetBody().GetUserData().handleBeginContact(contact);
}

We don't need to "dispatch" this contact on the class which doesn't do anything with this contact. For example the Hero doesn't manage PreSolve and PostSolve, so we don't need to call those functions. The Platform handles only the preSolve contact, so the others aren't needed.

What I suggest is to add a flag on physics objects to know if they should report contacts or not. This way the calls would be:

override public function BeginContact(contact:b2Contact):void {
    if (contact.GetFixtureA().GetBody().GetUserData().beginContact)
        contact.GetFixtureA().GetBody().GetUserData().handleBeginContact(contact);

    if (contact.GetFixtureB().GetBody().GetUserData().beginContact)
        contact.GetFixtureB().GetBody().GetUserData().handleBeginContact(contact);
}

This way it will resolve some draw calls. Adding this simple check won't decrease performances imho.

physics step problem

physics simulation is not same in different system, For example, on some system, a ball (like angry bird) can be shoot to 500 pixel with 60fps, but on other system, it will be shoot to 250 pixel with 30fps. on some system, you can't control the fps, it runs from 20-40 fps, you won't know it will be shoot how long.

I found the code problem:

package citrus.physics.nape
Nape.as Line89:

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

    // 0.05 = 1 / 20
    _space.step(0.05, 8, 8);

It should be:

    _space.step(timeDelta, 8, 8);

After that, it be solved.

Setting the MovingPlatform's Speed

Hi!

trying to port the box2D MovingPlatform to nape, I came across the fact that setting the speed parameter when creating a moving a platform in a state didn't change its speed. it still went at a max speed of 1.

If the parameter exists, I assumed that we would be able to change it.
My suggestion then would simply be that after normalizing the velocity vector, we'd multiply it by the speed like so :

//box2D version
                if (velocity.Length() > speed / _box2D.scale)
                {
                    //Still has further to go. Normalize the velocity to the max speed
                    velocity.Normalize();
                    velocity.Multiply(speed);
                    
                }

If that actually makes sense.

Unfortunately, this might re-open issue #8 , as with a speed of 2, the platform's friction is countered and the passenger can be thrown off of the platform when the platform suddenly change direction - and the fix in #8 will not work for horizontally moving platforms on box2D but also with nape.

This rises the question of whether or not this should be accepted as a default behavior or not by Citrus Engine, so it should be arbitrarily decided by you @alamboley , since its a "starter kit" .

Is a passenger supposed to stay on a platform, whatever the speed of the platform is (almost like in real life then) or should it drift off if its going too fast
(starting from a speed of 2 with box2D, and around 30 with nape apparently).

The very simple nape Port I have locally suffers from this "drifting off" effect even more than box2D.

I believe that in order to not have this effect going on, some movement calculations may need to be managed more by CitrusEngine other than just letting Nape or box2D do their thing and having CitrusEngine simply fixing things on every frame. for some extreme speed or cases, I know it shouldn't be the starter kit's problem, and devs should handle their extreme cases themselves.

but a speed of 2 is not an extreme case, so I thought asking this question was important, and help going forward.

Jumping twice (or more) in the air. [starling+nape]

Hello,
I have two Hero instances in my demo state.
I found that bug for a while, but I decided to trace the problem first , see if my code was causing the problem to not bother you for nothing.

Here's the specific case where this "bug" happens :
hero1 and hero2, both instances of Hero, are in the air after jumping. both their _onGround are false of course.
hero1 lands because he jumped earlier than hero2. then hero2 is able to jump again even if he has not landed.

So hero2 can double jump if perfectly timed, and vice versa.

Here's my theory for why this happens.
after being perfectly sure it had nothing to do with all my input experiments and seeing that the doublejump behavior was strictly linked to the other Hero instance and nothing else... then I thought nape was the problem. Looking into the code, perhaps handleBeginContact was the problem - it's the only place where _onGround is reset to true.

I added a trace in handleBeginContact :

if (e.arbiters.length › 0 && e.arbiters.at(0).collisionArbiter)
            {
                var angle:Number = e.arbiters.at(0).collisionArbiter.normal.angle * 180 / Math.PI;
                if ((45 ‹ angle) && (angle ‹ 135))
                {
                    trace(this._body.userData.myData.name);
                    _onGround = true;
                }
            }

hero1 is named player1, hero2 is named player2.

when I jump and land with just one of them, it traces

player1
player2

That confirms that both get their _onGround reset to true even if one can still be in the air (or even when one hasn't even moved).

I would guess it has something to do with arbiters and the fact that you get an index perhaps? or is it because both instances have the same CbType?
I have no idea how nape works internally, I can only guess, so maybe you can easily understand this I hope.

State transitions?

Make State transitions easy : having blur/fade in/fade out.. one State alreadu running pushing the other one on the left, etc.

No more foreach loop!

Test again performances between foreach loop and for loop (using ASC2.0) and make the change.

foreach (var a:CitrusSPrite in citrusVec){a.update()}
for (var i:uint = 0; i < tabLength; ++i) {citrusVec[i].update()}

Background CitrusSprite (that the camera should ignore)

I am trying to add a background sprite, that should not be affected by the camera.

In the update function of the Level, I added:
_background.y = -_camera.camProxy.y;

I have a ball dropping and the camera is following that ball.
As the ball gains speed, it actually goes off the camera bounds and the background sees an offset from the bottom, it does not keep following the camera position anymore for some reason.

Different sized animation frames resize to make all frames equal, resulting in frame distortion.

I am using TexturePacker to create my sprite sheet which is being pulled into my game using the AnimationSequence (starlingview). Everything seems to work fine except ive noticed that it seems whatever size the first frame of an animation is, it forces the following frames to also be that size. So for my hero run animation he has some frames where his legs are further apart then others and its causing certain frames to either squish or stretch. I'm not 100% sure its following the first frame size, but thats what it seems when i try to inspect it.

I'm sure im missing something here haha, but hopefully someone will know immediately. I feel like a fix might be to tell the hero bounding box (for lack of a better term) to resize to equal the current animation frames size but i havent been able to figure that out either. I appreciate any help i can get! Thank you in advance!!

StarlingView Group

The "group" property of the starling sprite doesn't seem to be getting properly set to match its citrus object's "group" property. This resulted in my images not layering properly.

In StarlingView.update():

    if (sprite.group != sprite.citrusObject.group)
updateGroupForSprite(sprite);

So it checks for a group difference and calls updateGroupForSprite(), which also does not update the group property.

private function updateGroupForSprite(sprite:StarlingArt):void {
// Create the container sprite (group) if it has not been created yet.
while (sprite.group >= _viewRoot.numChildren)
_viewRoot.addChild(new Sprite());

// Add the sprite to the appropriate group
Sprite(_viewRoot.getChildAt(sprite.group)).addChild(sprite);
}

I fixed it by adding:

sprite.group = sprite.citrusObject.group;

To the top of updateGroupForSprite().

SpriteView also seems to have this problem.

BitFlag.as / Inventory

(mentioning @makaimedia just so you can have a look at this as well)

Hi everyone,

I just want your advice on the BitFlag system , I seem to think we could add some simple methods to BitFlag if you think they're useful :

"toggle ALL" , "set" or even "set ALL"
I'm using a flag to keep all flags : STATE_ALL:uint = STATE_1 | STATE_2 | STATE_3;
to toggle all i just do toggleFlag(STATE_ALL). But having a toggleAllFlags would be much nicer? I feel that even setFlag() or setAllFlags(flags, default would be all flags)
could be a good addition.
toggling all flags only means setting all of them to NOT themselves is it?

Maybe also a function that would set all to false and one to true, or all to true and one to false. That's fairly easy though :

  1. set all to false and one specified flag to true

    current flags 1110011
    flag          0000100
    result flags  0000100  = flag.
  2. reverse

    current flags  1110011
    flag           0000100
    result flags   1111011  = xor flag 

not sure if the result is xor flag, bitwise operations knowledge is still a bit limited

Would that be of any use?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.