melonJS 0.9.7 - the mobile edition

739 views
Skip to first unread message

melonJS

unread,
May 6, 2013, 5:51:04 AM5/6/13
to mel...@googlegroups.com
Hi all,

I'm happy to announce that melonJS 0.9.7 is now officially available ! 

See here for more details :

thank you to all of you, and let's go with the next 0.9.8 version now :)

Cheers,
the melonJS team !

Aaron McLeod

unread,
May 6, 2013, 8:05:49 AM5/6/13
to mel...@googlegroups.com
Awesome! Now that the two-jams in a row week has passed, I can probably spend some time messing with 0.9.7, see if there's bugs i can potentially look at, and definitely start working on the spine implementation. Good times ahead!


--
You received this message because you are subscribed to the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to melonjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Aaron McLeod
http://agmprojects.com

Alexandre Ferreira

unread,
May 6, 2013, 8:49:59 PM5/6/13
to mel...@googlegroups.com
Lovely new documentation site, even left some attributes and methods, but, I know you guys have a lot of work! Anyways I'm really happy to take part of melonJS community, for your simplicity and efficiency, for me, it's the best lib that I had the opportunity to test!

Keep going, guys! :)

melonJS

unread,
May 6, 2013, 11:08:22 PM5/6/13
to mel...@googlegroups.com
Thank you Alexandre :)

If you did notice missing stuff in the documentation, would you mind filling a ticket, so that we can fix them ?

thanks !

Alexandre Ferreira

unread,
May 6, 2013, 11:26:55 PM5/6/13
to mel...@googlegroups.com
Oh, yes! I will! :)

Ahmad Takhimi

unread,
May 8, 2013, 1:26:23 AM5/8/13
to mel...@googlegroups.com
Hi. Any changes or updates on input for touch screen since the title called mobile edition which means dont have any keyboard by default. Any plugin for that ?



TQ

Jay Oster

unread,
May 8, 2013, 3:00:15 AM5/8/13
to mel...@googlegroups.com
Hi Ahmad,

melonJS still has keyboard and mouse input by default. It's labeled "mobile edition" because the release adds a lot of new features and support directly for mobile platforms. There hasn't been any big changes for touch input, though there will be some changes coming in 0.9.8 to support `touches` and `changedTouches` as separate properties of `me.input`: https://github.com/melonjs/melonJS/issues/210

tim....@rentermonsters.com

unread,
May 14, 2013, 3:16:03 AM5/14/13
to mel...@googlegroups.com
Hey guys,

I've been stuck on an issue for a little while with the new melonJS, and I was wondering if you guys could help me out. I was trying to follow suggestions I've seen on some other posts about anchor points and such things, but my hitboxes/collision in my game is working very strangely in 0.9.7. 

The biggest problem I'm having is that my bullets no longer work, and I am getting an error in the debugger from within the melonJS file itself. I'm going to copy/paste the problem, and the code for my bullet variable. Any help would be much appreciated!

The debugger error says "TypeError: r is null"  : melonJS-9.8.7.js(line 2318)

That error appears anytime I shoot a projectile.

Now, this is what my bullet.js file looks like.

var bullet = me.ObjectEntity.extend({

init: function(x, y, settings){
this.parent(x, y, settings);
this.collidable = true;
this.gravity = 0;
this.type = me.game.bullet;
var travelLeft = false;
this.inViewport = true;
},
update: function(){
if(!this.inViewport || this.vel.x == 0){
me.game.remove(this);
}
//check for collision
var res = me.game.collide(this);
if(res){
if (res.obj.type != me.game.COLLECTABLE_OBJECT && res.obj.bullet_type != 'liche_bullet' && res.obj != me.game.player){
me.game.remove(this);
}
}
this.updateMovement();
return true;
}
});

var licheboss_bullet = me.ObjectEntity.extend({

init: function(x, y, settings){

settings.image = 'bullet_licheboss';
settings.spritewidth = 30;
this.parent(x, y, settings);
this.collidable = true;
this.gravity = 0;
this.type = me.game.ENEMY_OBJECT;
this.bullet_type = 'licheboss_bullet';
this.setVelocity(licheboss_shootSpeed, liche_Jump);
this.addAnimation( "shoot", [0,1,2] );
var travelLeft = false;
this.inViewport = true;
},
update: function(){
if(!this.inViewport || this.vel.x == 0){
me.game.remove(this);
}

this.pos.x += this.vel.x;
//this.setCurrentAnimation( "shoot" );
//check for collision
var res = me.game.collide(this);
if (res){
if (res.obj.type != me.game.COLLECTABLE_OBJECT && res.obj.type != me.game.bullet && res.obj != me.game.player){
me.game.remove(this);
}
}

this.parent(this);
return true;
}
});

var liche_bullet = me.ObjectEntity.extend({

init: function(x, y, settings){

this.direction = settings.direction;
this.parent(x, y, settings);
this.collidable = true;
this.gravity = 0;
this.type = me.game.ENEMY_OBJECT;
this.bullet_type = 'liche_bullet';
this.setVelocity(liche_shootSpeed, liche_shootSpeed);
this.addAnimation( "shoot", [0] );
var travelLeft = false;
this.inViewport = true;

},
update: function(){
if(!this.inViewport || this.vel.x == 0){
me.game.remove(this);
}

if (this.direction == true)
{
this.pos.x += this.vel.x;
}
else
{
this.pos.x -= this.vel.x;
}
//check for collision
var res = me.game.collide(this);
if (res){
if (res.obj.type != me.game.COLLECTABLE_OBJECT && res.obj.type != me.game.bullet && res.obj != me.game.player && res.obj.type != me.game.ENEMY_OBJECT){
me.game.remove(this);
}
}

this.parent(this);
return true;
}
});





I'd love to know if there's anything here that needs to be updated to 0.9.7. Also, if it helps, here's the code in our player.js file for when the bullet is actually shot:

if(faceLeft != true)
{
var shot = new bullet(this.pos.x + 42, this.pos.y + this.bulletOffsetY,{image: 'bullet', spritewidth: 16});
}
else
{
var shot = new bullet(this.pos.x - 24, this.pos.y + this.bulletOffsetY,{image: 'bullet', spritewidth: 16});
shot.flipX(true);
}

Thanks in advance guys. Looking forward to hearing something! We really do want to eventually show you guys what we've been working on. I promise it's worth the wait and suspense. :)

Jason Oster

unread,
May 14, 2013, 3:37:13 AM5/14/13
to mel...@googlegroups.com
Why is the file named "melonJS-9.8.7.js" ? That's kind of weird. ;)

More weird is that line 2318 on the release build of 0.9.7 doesn't have an "r"; it's actually within the property definition for me.Rect.top. Nothing really sticks out as being a problem, but you should always return directly after removing the object... It's no longer in the game engine, why are you still updating it? :p

--
You received this message because you are subscribed to a topic in the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/melonjs/DSFwiDkUqvQ/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to melonjs+u...@googlegroups.com.

melonJS

unread,
May 14, 2013, 3:46:09 AM5/14/13
to mel...@googlegroups.com, j...@kodewerx.org
Actually there is someting :

Since version 0.9.7 me.ObjectEntity does not inherit anymore from me.AnimationSheet; me.SpriteObject, which means that all sprites related functions are not anymore accessible directly from the objectEntity itself. And the objectEntity corresponding drawable part is now accessible through the entity 'renderable' property.

so for example, this :
this.addAnimation( "shoot", [0] );
should become this :
this.renderable.addAnimation( "shoot", [0] );

Olivier.



melonJS

unread,
May 14, 2013, 3:56:37 AM5/14/13
to mel...@googlegroups.com, j...@kodewerx.org
also, be sure to keep an eye on the upgrade guide :

Looking forward for a demo :)

tim....@rentermonsters.com

unread,
May 15, 2013, 2:35:19 AM5/15/13
to mel...@googlegroups.com, j...@kodewerx.org
Hey guys,

Thanks for the great input. Olivier, I added the "renderable" part, but I still get the same errors. I made sure to change it to renderable in all the other files, this one I accidentally overlooked, haha. This really has me stuck because my bullets fire, I have the debug hitbox on to ensure they are where I think they are, but they no longer collide with enemies anymore. I'll look through the upgrade guide some more. Any other advice you could throw my way would be great. 

Also, Jason, the reason my MelonJS file was named differently is because we use version control software. I already had a beta version of melon-JS on Perforce, and I don't control deleting stuff from it, so I wanted to put on the new melon, so I just renamed it for the time being.

As always, thanks guys! Looking forward to anything else you've got.

Best regards,

Tim

tim....@rentermonsters.com

unread,
May 15, 2013, 3:00:02 AM5/15/13
to mel...@googlegroups.com, j...@kodewerx.org, tim....@rentermonsters.com
I tried switching between melon files, and it stopped giving me errors. However, my bullets still don't collide with anything. It's strange because the player and enemies can collide just fine. Strange, strange problems!

Jason Oster

unread,
May 15, 2013, 3:11:03 AM5/15/13
to mel...@googlegroups.com
I just noticed all of your bullet classes have this check for collision detection:

res.obj != me.game.player

Does this mean you never want your player object to collide with bullets? And what is `me.game.player` anyway? Are you reusing the `me` namespace for game-specific stuff? :\

Final thought; have you tried using `onCollision` callbacks instead of checking the return value of the collide method?

On May 15, 2013, at 12:00 AM, tim....@rentermonsters.com wrote:

I tried switching between melon files, and it stopped giving me errors. However, my bullets still don't collide with anything. It's strange because the player and enemies can collide just fine. Strange, strange problems!

tim....@rentermonsters.com

unread,
May 15, 2013, 7:15:58 PM5/15/13
to mel...@googlegroups.com, j...@kodewerx.org
Hey Jason,

As always, appreciate the response. We don't want our bullets colliding with the player because only the player shoots bullets. The enemies in our game are mostly archetypal monsters. Things like zombies, mummies, ghosts,vampires, etc. Originally, our bullets were hurting the player character, so we didn't want that. We have some other custom bullets that one of our bosses uses. I'm at work right now so I don't have access to the code, but I'm pretty sure the me.game.player was being reused from an example I found a while back. I'll have to investigate that further. 

As far as the onCollision callbacks, I'll have to look into that. It's very strange, because everything you're seeing was working perfectly pre 0.9.7. I've been scratching my brain over this for about two weeks. I'll look into your suggestions and write back with the results. If that doesn't work, I might have permission to send you and Olivier the code, because we trust you guys with it since you've been such a huge help. 

I'll write back tonight at some point hopefully.

-Tim

Jay Oster

unread,
May 16, 2013, 12:57:30 AM5/16/13
to mel...@googlegroups.com, j...@kodewerx.org, tim....@rentermonsters.com
That makes sense. One thing I was curious about; where is the code that damages enemies when they are hit by bullet objects? The bullet classes simply remove themselves when a collision occurs, so I'm going to guess you are handling the damage part in an onCollision callback on the enemy classes?

Michael Luyties

unread,
May 16, 2013, 2:48:36 PM5/16/13
to mel...@googlegroups.com, j...@kodewerx.org, tim....@rentermonsters.com
Hey guys,

So I believe I've found a solution to this problem, but I'm worried that I am bandaiding the problem or there is another note we need to add to the upgrade guide...

If I have an enemy that is 32x32, the green debug box shows correctly around them, but no red collision box. I have to add this line to get it to appear correctly and fix the collision issue:

this.updateColRect( 0, 32, -16, 32 );

Do I need to go in and manually set collision boxes for every entity or is there another solution?


Thanks,
Mike

Jay Oster

unread,
May 16, 2013, 7:13:55 PM5/16/13
to mel...@googlegroups.com, j...@kodewerx.org, tim....@rentermonsters.com
Works for me ... ObjectEntity's collisionBox takes on the position and size of the object when created: https://github.com/melonjs/melonJS/blob/master/src/entity/entity.js#L542 When you use `adjustColRect()`, you're just changing the size of its collisionBox.

Are you sure you aren't doing something strange like changing the width/height after creating the entity, or just not calling `this.parent()` correctly in your ObjectEntity constructor?

melonJS

unread,
May 16, 2013, 10:55:32 PM5/16/13
to mel...@googlegroups.com, j...@kodewerx.org, tim....@rentermonsters.com

Hi Jason,

On a side but related topic, for the next 0.9.8 version I think it would be nice as well to simplify the current me.Rect implementation and get rid of all that code that manage a rect within a rect. (who does not like more simple code!)

With Object Entity and Renderable now being managed completely differently, and renderable display alignment being set through the object entity anchorPoint, we could now use the entity inherited me.Rect coordinates as the collision rect.

What do you think, would this be somehow in line with the new collision implementation, and possibly a later integration with a chipmunk plugin ? from what I can see, melonJS could use the regular AABB rect from the object entity for collision, and then we are free to add a body property when using with chipmunk or box2d.

Michael Luyties

unread,
May 16, 2013, 11:35:23 PM5/16/13
to mel...@googlegroups.com, j...@kodewerx.org, tim....@rentermonsters.com
Hey Jay,

I've figured out the problem. I only ever set the width of the entity previously (based on the tutorial) and now it is requiring that the height is also set. But, once I dictate that as well, it works perfectly =)

Now I'm having two other issues that didn't occur in 0.9.6:

1) When I shoot an enemy to a certain level, they enter an "incapacitated" state and lose collision before dying. Previously, I just set this.collidable = false; so that I could shoot through the enemy at that point and had no problems. They went into the state, animated, then died and disappeared. Now, when I set this.collidable = false; they just instantly fall right through the world. My understanding is that this flag is for object to object collision, not world. This worked fine in 0.9.6 and am wondering if there is something else that may have changed that I need to work around?

2) I'm getting this error on one of my 2 health drops:

TypeError: frame is undefined
this.offset = frame.offset;
melonJS-0.9.7-min.js (line 3417)

This line works perfectly:  this.health_drop = new Health_Entity(this.pos.x, this.pos.y,{image: 'health_drop', spritewidth: 16, spriteheight: 16, origin: "drop"});
This line does not:           this.health_drop = new Health_Entity(this.pos.x, this.pos.y,{image: 'health_drop_small', spritewidth: 10, spriteheight: 10, origin: "drop"});

If I swap out the image of the small drop with the large one, it works fine. Both of these images were in use before and I'm not sure what could be causing this.

Sorry for all the questions, I'm just trying to get over the hump and get my game back in to a happy state after the engine update =)


Thanks,
Mike

Michael Luyties

unread,
May 16, 2013, 11:40:28 PM5/16/13
to mel...@googlegroups.com, j...@kodewerx.org, tim....@rentermonsters.com
Yay! I actually figured out the second problem, so please ignore =)

melonJS

unread,
May 16, 2013, 11:44:30 PM5/16/13
to mel...@googlegroups.com, j...@kodewerx.org, tim....@rentermonsters.com
About the first one, this is because the collidable property is now also use to determine if we should collide with the world (tiled layer), this in preparation of further coming changes.

To restore your previous behavior, I would recommend using a isAlive boolean that you set to false when required, and do nothing from your onCollision function.

For the second one, a piece of code, and the corresponding line in the un-minified version of melonJS would better help :)

Michael Luyties

unread,
May 16, 2013, 11:46:56 PM5/16/13
to mel...@googlegroups.com, j...@kodewerx.org, tim....@rentermonsters.com
Ah, okay. I figured that might be the case. I'll handle it on the collision side of the enemy then. Thanks for all your help!

melonJS

unread,
May 16, 2013, 11:48:53 PM5/16/13
to mel...@googlegroups.com, j...@kodewerx.org, tim....@rentermonsters.com
sorry for this last one, and it was actually missing from the upgrade guide in the wiki :)

Michael Luyties

unread,
May 16, 2013, 11:55:33 PM5/16/13
to mel...@googlegroups.com, j...@kodewerx.org, Tim Peter
Not a big deal at all. Just trying to sort everything out and the more information on here, the easier it is for the next guy =)


--
You received this message because you are subscribed to a topic in the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/melonjs/DSFwiDkUqvQ/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to melonjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Sincerely,
Mike Luyties, CEO of RenterMonsters.com

Jason Oster

unread,
May 17, 2013, 12:17:52 AM5/17/13
to mel...@googlegroups.com
That would be great! :) I know I've tried to simplify the rect-within-a-rect thing on two separate occasions (only remembering why it is needed after failing the second time!)

Kilian

unread,
May 24, 2013, 2:46:10 AM5/24/13
to mel...@googlegroups.com
Hi everybody,
I finally came around in testing the final 0.9.7,
previously I was using a build from early April.

I noticed one problem in my project after the
upgrade. I'm using an ObjectEntity with an
AnimationSheet in the renderable. There's
only one animation with an callback afterwards:

        this.renderable.addAnimation("effect",[0,1,2,3,4,5]);
        this.renderable.setCurrentAnimation("effect", function() {me.game.remove(this)}.bind(this));

With the final 0.9.7 the 0th / first frame is played
and visible again before the entity is removed.
Although both builds returning 0 when calling:

        this.renderable.getCurrentAnimationFrame();

before the remove.

I've already checked me.AnimationSheet from
both builds in diff. I can't make out what
changes could affect this. Maybe something
with the callback? Maybe me.AnimationSheet
is the wrong place to look for the problem?
Maybe a timing problem? I don't know ;-)

eld...@gmail.com

unread,
May 24, 2013, 7:19:09 AM5/24/13
to mel...@googlegroups.com
Thank you very much!
I'm just starting to use Melon due to your update/progress high rate!
continue the good work.
Hopefully, I'll be able to release a multiplayer library (I"m developing an RTS) that will include lag compensation, interpolation and prediction.

If you have skype, I'll be more then happy to go into details and check with you how will it be best to implement.

skype: eldady87
Eldad.

Jay Oster

unread,
May 24, 2013, 1:27:21 PM5/24/13
to mel...@googlegroups.com
Hi Kilian,

This post explains what you are seeing, and how to do what you want: https://groups.google.com/d/msg/melonjs/tig9Qzo6Pjk/EO2t6IlfT6YJ

Jay Oster

unread,
May 24, 2013, 1:44:56 PM5/24/13
to mel...@googlegroups.com
Also, the reason you see the first frame in the official release and not in the 0.9.7 beta is because the `me.remove()` method has been changed to defer by default (because it is unsafe to call during the game loop update). The defer will cause the object to be removed only after the current game loop iteration ends.

You actually have a few options to choose from: The one I linked previously is recommended in most cases. (Set the frame index in the callback and pause the animation.) Another option is making the object invisible in the callback. (this.visible = false;) And actually, there is code in melonJS do do this for you on remove, except it was also deferred by the update! I suppose that could be moved outside of the defer...

Kilian

unread,
May 25, 2013, 1:19:04 AM5/25/13
to mel...@googlegroups.com
Thanks Jason, that makes sense to me :)
I've used your hint from the linked topic and
it works fine this way.

Jay Oster

unread,
May 25, 2013, 3:51:39 PM5/25/13
to mel...@googlegroups.com
Now that I look, the visibility is being set to false at the proper time by the remove, but the object will still request to be drawn! So, I think this will be a better solution ... 0.9.8 will prevent resetting to the first frame when your animation callback returns false:


If you have a callback that returns false, you will probably want to remove the object, or pause the animation. Otherwise your callback will be called repeatedly at the end of the animation.

gint...@gmail.com

unread,
May 28, 2013, 1:10:28 PM5/28/13
to mel...@googlegroups.com
Great performance improvement over mobile devices,but still I can't get a sound on Android native WebKit browser using Android 2.3.7 and 2.2.

Aaron McLeod

unread,
May 28, 2013, 1:14:41 PM5/28/13
to mel...@googlegroups.com
Android 2 is pretty old as far as devices go. Does the browser version on that os support the audio API?

Aaron McLeod
http://agmprojects.com


On Tue, May 28, 2013 at 1:10 PM, gint...@gmail.com <gint...@gmail.com> wrote:

Great performance improvement over mobile devices,but still I can't get a sound on Android native WebKit browser using Android 2.3.7 and 2.2.

--
You received this message because you are subscribed to the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to melonjs+u...@googlegroups.com.

Jay Oster

unread,
May 28, 2013, 6:03:51 PM5/28/13
to mel...@googlegroups.com
  • HTML5 audio element is only supported on Android browser since 2.3, and if it's anything like iOS, it's only barely working anyway.
  • Web Audio is not supported on Android as of 4.2
:(

Aaron McLeod

unread,
May 28, 2013, 6:15:37 PM5/28/13
to mel...@googlegroups.com
ah le crap. Trying to find something concrete, but cocoonjs supports 2.3 and up i believe. So maybe its audio implementation will work?
--
Aaron McLeod
http://agmprojects.com

Jason Oster

unread,
May 28, 2013, 6:47:02 PM5/28/13
to mel...@googlegroups.com, mel...@googlegroups.com
I'll try it this week. I have access to an older Android phone running something in 2.x (I think)
You received this message because you are subscribed to a topic in the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/melonjs/DSFwiDkUqvQ/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to melonjs+u...@googlegroups.com.

Ahmad Takhimi

unread,
Jun 2, 2013, 10:28:33 PM6/2/13
to mel...@googlegroups.com
Hi


I think I found a bug. With latest version on melonjs (0.9.8) and the latest platformer example. May even be in earlier version also since I didnt notice it.

Let say example of metal slug kind of game where the user can control player like this:-

Right Arrow+ Up Arrow + Jump (Player moves to right, while jumping and look up) - so that the player can shoot any enemy object above.

For the bug I found in latest platformer build.

I can do like this

Right Arrow+ Up + Jump (Move to the right while jumping and even double jump) - I purposely press Up arrow when doing this.

But I cant do this

Left Arrow + Up+ Jump (I cant do the same when I want to move to left and jump)

I hope this is clear.

Tested with latest IE10 and Firefox. Same bug. Or is it my Laptop ?





 

Jay Oster

unread,
Jun 2, 2013, 11:44:33 PM6/2/13
to mel...@googlegroups.com
Hi Ahmad,

Try binding your movement actions to other keys. If that doesn't change anything, it may be a bug in code somewhere. Can you share an example that demonstrates the issue? That will also help by having the code tested on other hardware.

Michael Luyties

unread,
Jun 2, 2013, 11:47:40 PM6/2/13
to mel...@googlegroups.com

I believe this is actually your keyboard. I have the same problem in my game but it works just fine when bound to other keys. It's just certain key combos.

Ahmad Takhimi

unread,
Jun 3, 2013, 12:10:28 AM6/3/13
to mel...@googlegroups.com

Hi

Like I mention before, this is from the Platformer example in GitHub directory. https://github.com/melonjs/melonJS/tree/master/examples/platformer

 I didnt do any change of the codes. Just  press Right+Up+X , then try Left+Up+X combos when playing.


I know Up arrow dont have any key bindings in the example. It is just habit of mine when playing platformer games especially after playing metal slugs. Hehe.


 

Regards



Ahmad Takhimi

unread,
Jun 3, 2013, 12:25:19 AM6/3/13
to mel...@googlegroups.com
You are right Michael,

It turns out that there is keybinding in the platformer example codes for Up. If I change the binding to WSAD and space for jumps it works ok.

So is this engine bug ? Or my laptop ?

.
Message has been deleted

sn

unread,
Jun 3, 2013, 7:47:35 AM6/3/13
to mel...@googlegroups.com
It's controller of your keyboard issue.

понедельник, 3 июня 2013 г., 8:25:19 UTC+4 пользователь Ahmad Takhimi написал:
Message has been deleted

Jay Oster

unread,
Jun 4, 2013, 3:42:56 AM6/4/13
to mel...@googlegroups.com, serni...@gmail.com
Here are a few links explaining the issue (it's a hardware limitation, not a software bug)

Ahmad Takhimi

unread,
Jun 4, 2013, 4:20:42 AM6/4/13
to mel...@googlegroups.com, serni...@gmail.com
Thanks.

So funny, my sony vaio got this problem, my cheapo dell vostro dont have. Later will test with lenovo laptop.

Alot of people complain about this in forums.

So guys, if you thinking about buying sony vaio s series, better think again since the kb ghosting limitation.


Regards.

Aaron McLeod

unread,
Jun 4, 2013, 8:26:48 AM6/4/13
to mel...@googlegroups.com
I know a lot of platformer games that only used arrow keys and buttons for movement, such as those on the gameboy, didnt really let you aim+jump+shoot but just jump+shoot or aim+shoot. You can use that constraint to potentially design levels. Another option would be to implement the mouse to aim, but that might add a lot more complexity, as you get the potential for 360 degrees, instead of 45 degree increments.


--
You received this message because you are subscribed to the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to melonjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Katarzyna Ostrowicz

unread,
Sep 10, 2013, 10:24:54 AM9/10/13
to mel...@googlegroups.com, j...@kodewerx.org, tim....@rentermonsters.com
I'm getting similar problem with melonJS 0.9.8. Which occurs when I try to load up one of my player sprites and start the level:

TypeError: frame is undefined

Can you explain how did you figured the issue out?

Aaron McLeod

unread,
Sep 10, 2013, 10:30:00 AM9/10/13
to mel...@googlegroups.com, j...@kodewerx.org, tim....@rentermonsters.com
Wrong thread? 

Anyways, I would double check your setAnimation calls and ensure you're not going over the number of frames in an image. So if you have a 4 frame animation image, that is 128 x 32, and you have a walk animation, make sure you don't go outside of the index like so:

this.renderable.setAnimation('walking', [0,1,2,3,4,3,2,1], 1);

Since there is only 4 frames, specifying the index of 4 would go out of bounds in the zero indexed array.


--
You received this message because you are subscribed to the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to melonjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Katarzyna Ostrowicz

unread,
Sep 10, 2013, 10:33:01 AM9/10/13
to mel...@googlegroups.com, j...@kodewerx.org, tim....@rentermonsters.com

The thing is I have this problem with standard 0.9.8 not mobile edition, and I don't know why this happens
I don't do any of the above in my web game.  


And this is the only topic that has mentioned about it.
And it does not happen always when I try to load the level. Is it possible that the image is the issue?

Katarzyna Ostrowicz

unread,
Sep 10, 2013, 10:51:35 AM9/10/13
to mel...@googlegroups.com, j...@kodewerx.org, tim....@rentermonsters.com

Maybe this will put a little light on my issue. I've got this personal loading system written and 2 different sprites for player character. 

When it comes to loading level the one in blue dress sometimes gives this "frame" error, and sometimes not.


Code below:

function loadLevel(type,number)
{
var path="static/tiled/";
if(type=="level")
path+="levels/";
else if(type=="gate")
path+="gates/";
else if(type=="challenge")
path+="challenges/"
path+=number+"/";

$.ajax({
type: "GET",
url: "/get_maps",
async: false,
data: { path: path },
success: function(data) { 
if (DEBUG) console.log(data.result);
loadResources(data.result,type);
}
});
}

function loadResources(resources,levelType)
{
var callback = allLoadedFactory(resources.length, function () { 
loadCharacter();
//resetGame();
me.state.change(me.state.PLAY,"area001",levelType); 
});
for (var i = 0; i < resources.length; i++) {
me.loader.load({ name : "area00" + (i + 1), type : "tmx", src : resources[i] }, callback);
}
}

function allLoadedFactory(total, onload) {
    var count = 0;
    return function () {
        count++;
        if (count >= total && typeof(onload) === "function") {
            onload();
        }
    };
    
}


function loadCharacter()
{
loadPlayerTexture(getCharacter());
}

function loadPlayerTexture(character)
{
if (DEBUG) console.log("started loading: "+character); THIS IS THE LAST LOG and then gives error
var callback = allLoadedFactory(1, function () { if (DEBUG) console.log('character_loaded'); });
if(character=="Linda")
{
me.loader.load({name: "player_texture", type: "image", src: "static/tiled/sprites/lidia_right.png"});
}
else if(character=="Shura")
{
me.loader.load({name: "player_texture", type: "image", src: "static/tiled/sprites/shura_right.png"});
}
}

Jason Oster

unread,
Sep 10, 2013, 12:48:55 PM9/10/13
to Katarzyna Ostrowicz, mel...@googlegroups.com, tim....@rentermonsters.com
The loading code you shared looks fine. Where is the "player_texture" reference actually used? I'm guessing it's defined in your map as an object. In that case, it would help to share the map, and any other classes required to insatiable your player objects.

Katarzyna Ostrowicz

unread,
Sep 10, 2013, 12:53:17 PM9/10/13
to mel...@googlegroups.com, Katarzyna Ostrowicz, tim....@rentermonsters.com, j...@kodewerx.org
{name: "player_texture", type: "image", src: "static/tiled/sprites/shura_right.png"}, 

This is what is preloaded as g_resources.
But when the level is loaded the character id itself is taken from DB by ajax and converted to "Linda" or "Shura". 

Jason Oster

unread,
Sep 10, 2013, 3:45:50 PM9/10/13
to mel...@googlegroups.com, mel...@googlegroups.com, Katarzyna Ostrowicz, tim....@rentermonsters.com, j...@kodewerx.org
I see where it's loaded in the code you provided I'm now interested in where it is *used*. Because the error you pasted occurs in entity initialization.
--
You received this message because you are subscribed to a topic in the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/melonjs/DSFwiDkUqvQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to melonjs+u...@googlegroups.com.

Katarzyna Ostrowicz

unread,
Sep 11, 2013, 4:16:47 AM9/11/13
to mel...@googlegroups.com, Katarzyna Ostrowicz, tim....@rentermonsters.com, j...@kodewerx.org
Well, it's used twice.

While starting simple gameplay and when starting challenges - which basically are the same, but load up different levels, counted differently in the database.

For standard gameplay in button starting level:
b.onClick = function() {
if(startGame()=='start_game')
{
levelNumber = parseInt(this.text);
levelType = "level";
loadLevel(levelType,levelNumber);
return true;
}
else
{
handle.captionText2 = "no tokens";
}
}
}

And that works always fine for both characters (startGame() is a method reseting default values for the app server - flask).

In challenges I have something simmilar:

b_play.onClick = function()
{
if (DEBUG) console.log("PLAY CHALLENGE ID: "+this.challengeID+" NUMBER: "+this.challengeNumber);

if(startChallenge(this.challengeID,this.ifChallenger)=='start_game')
{
levelNumber = parseInt(this.challengeNumber);
levelType = "challenge";
loadLevel(levelType,levelNumber);
return true;
}

}

Which should not be a problem. shura_right loads up fine all the time, lidia_right - sometimes loads up for a challenge, for standard gameplay - works fine.
Message has been deleted

Katarzyna Ostrowicz

unread,
Sep 11, 2013, 4:24:25 AM9/11/13
to mel...@googlegroups.com, Katarzyna Ostrowicz, tim....@rentermonsters.com, j...@kodewerx.org
Also PlayScreen code:

var PlayScreen = me.ScreenObject.extend(
{

onResetEvent: function(level,levelType) {
this.levelType = levelType;
me.levelDirector.loadLevel(level);
if (DEBUG) console.log(levelType);
me.input.bindKey(me.input.KEY.X, "jump", true);
me.input.bindKey(me.input.KEY.Z, "shoot", true);
me.game.addHUD(0, 550, 800, 100);
me.game.HUD.addItem("score", new ScoreObject(0, 30));
STARTTIME = me.timer.getTime();
score_saved = false;
if(levelType == "level" || levelType == "gate")
{
$.ajax({
type: "GET",
url: "/get_lives",
async: false,
success: function(data) {
if(DEBUG) console.log("Lives: "+data.result); 
me.game.HUD.addItem("lives", new LifeObject(100, 30, data.result));
}
});
me.game.HUD.addItem("time", new TimeObject(250, 30, this.levelType,0.000));
this.time('start');
}
else if(levelType == "challenge")
{
this.challengeTime = parseInt(getValue('challenge_time'))
me.game.HUD.addItem("time", new TimeObject(250, 30, this.levelType,this.challengeTime));
}
me.game.sort();
},
 
onDestroyEvent: function() {
// remove the HUD
me.game.disableHUD();
me.input.unbindKey(me.input.KEY.X);
me.input.unbindKey(me.input.KEY.Z);
if (DEBUG) console.log("destroy playscreen");
  //  me.audio.stopTrack();
},
(...)
});


And Player's:


var PlayerEntity = me.ObjectEntity.extend({
init: function(x, y , settings)
{
this.parent(x, y, {
image : "player_texture",
spritewidth : 64,
spriteheight: 64,
});
//this.collidable = true;
this.setVelocity(3,15);
this.updateColRect(13,38,12,48);
this.anchorPoint.set(0.0,0.0); //0.9.7
me.game.viewport.follow(this.pos,me.game.viewport.AXIS.BOTH)
if (DEBUG) me.debug.renderHitBox = true;
if (DEBUG) console.log("created player");
this.type = "PLAYER";
this.walkingLeft = false;
},

(...)
});

Jay Oster

unread,
Sep 11, 2013, 7:30:55 PM9/11/13
to mel...@googlegroups.com, Katarzyna Ostrowicz, tim....@rentermonsters.com, j...@kodewerx.org
ok, *probably* what's happening is your load callbacks are firing before the images are actually loaded from the server. Evidenced by not providing a callback to `me.loader.load()` in your loadPlayerTexture() function.

You create a callback variable using allLoadedFactory(), but that callback is not actually used. Probably the allLoadedFactory() function should be called in the loader callbacks?

Katarzyna Ostrowicz

unread,
Sep 12, 2013, 4:12:59 AM9/12/13
to mel...@googlegroups.com, Katarzyna Ostrowicz, tim....@rentermonsters.com, j...@kodewerx.org
So you mean like:


function loadPlayerTexture(character)
{
if (DEBUG) console.log("started loading: "+character);
var callback = allLoadedFactory(1, function () { if (DEBUG) console.log('character_loaded'); });
if(character=="Linda")
{
me.loader.load({name: "player_texture", type: "image", src: "static/tiled/sprites/lidia_right.png"}, callback);
}
else if(character=="Shura")
{
me.loader.load({name: "player_texture", type: "image", src: "static/tiled/sprites/shura_right.png"}, callback);
}
}

Because I'm already a little lost in my work. >_<

Jason Oster

unread,
Sep 12, 2013, 12:20:39 PM9/12/13
to mel...@googlegroups.com, mel...@googlegroups.com, Katarzyna Ostrowicz, tim....@rentermonsters.com, j...@kodewerx.org
Possibly!

You use the same pattern in other areas using me.loader.load()

What really confuses me is how the 'all loaded' even continues when not all of its callbacks have run (this one, specifically)
--

Katarzyna Ostrowicz

unread,
Sep 12, 2013, 12:48:35 PM9/12/13
to mel...@googlegroups.com, Katarzyna Ostrowicz, tim....@rentermonsters.com, j...@kodewerx.org
That's really confusing, because the error was totally my fault as I did not retyped the code as you provided for me here.

And it ALWAYS worked in the standard gameplay. But not in challenge.

Jason Oster

unread,
Sep 12, 2013, 1:05:11 PM9/12/13
to mel...@googlegroups.com, mel...@googlegroups.com, Katarzyna Ostrowicz, tim....@rentermonsters.com, j...@kodewerx.org
I just noticed your use of allLoadedFactory is not what was originally intended, since it is called multiple times. I suppose what you want then is modifying it to be useful under that pattern.

But then there's no guarantee that the callback won't fire prematurely... Handling that edge case is probably more trouble than it is worth. :x

On Sep 12, 2013, at 9:48 AM, Katarzyna Ostrowicz <archa...@gmail.com> wrote:

That's really confusing, because the error was totally my fault as I did not retyped the code as you provided for me here.

And it ALWAYS worked in the standard gameplay. But not in challenge.

Jay Oster

unread,
Sep 12, 2013, 5:29:44 PM9/12/13
to mel...@googlegroups.com, Katarzyna Ostrowicz, tim....@rentermonsters.com, j...@kodewerx.org
Here's an example of such modification:

var allLoadedFactory = (function () {
    // Total number of items to be loaded
    var total = 0;

    // Track number of currently loaded items
    var loaded = 0;

    // List of callbacks
    var callbacks = [];

    // expected: The number of items that I want to load
    // onload: A callback to run when all items have loaded
    return function (expected, onload) {
        total += expected;

        // Add callback to list
        if (typeof(onload) === "function" && callbacks.indexOf(onload) < 0) {
            callbacks.push(onload);
        }

        // Fire the onload function(s) when all items have been loaded        
        return function () {
            loaded++;
            if (loaded >= total) {
                // Fire all callbacks
                for (var i = 0; i < callbacks.length; i++) {
                    callbacks[i]();
                }

                // Reset factory
                total = 0;
                loaded = 0;
                callbacks = [];
            }
        };
    };
})();

This one can be called multiple times, and it just increases the total number of items that it expects to load. It will also allow multiple `onload` callbacks, if you want. Or you can specify the same onload each time, and it will only be called once when everything has loaded.

Here's an example for using it:

// An onload callback
function done() {
    console.log("done!");
}

// Run the factory, expecting to load 2 items by the first callback
var x = allLoadedFactory(2, done);
// And 1 more item by the second callback
var y = allLoadedFactory(1, done);

// Simulate asynchronous loads; the callbacks may run out-of-order
x();
y();
x();
// -> done!

It's tricky, but it works!

The one edge case I mentioned in the last post would occur if x() was called twice *before* the second call to allLoadedFactory(). So allLoadedFactory() should always be called sequentially, never asynchronously!

On Thursday, September 12, 2013 10:05:11 AM UTC-7, Jay Oster wrote:
I just noticed your use of allLoadedFactory is not what was originally intended, since it is called multiple times. I suppose what you want then is modifying it to be useful under that pattern.

But then there's no guarantee that the callback won't fire prematurely... Handling that edge case is probably more trouble than it is worth. :x

On Sep 12, 2013, at 9:48 AM, Katarzyna Ostrowicz <arch...@gmail.com> wrote:

That's really confusing, because the error was totally my fault as I did not retyped the code as you provided for me here.

And it ALWAYS worked in the standard gameplay. But not in challenge.

--
You received this message because you are subscribed to a topic in the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/melonjs/DSFwiDkUqvQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to melonjs+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages