Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticket #15 - inheritance / composition #165

Merged
merged 8 commits into from
Mar 3, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/dirtyRect/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<body bgcolor="white">
<div id="jsapp">
<script type="text/javascript" src="../../build/melonJS-0.9.7.js"></script>
<script type="text/javascript" src="screenObj.js"></script>
<script type="text/javascript" src="gameObj.js"></script>
<script type="text/javascript" src="screens.js"></script>
<script type="text/javascript" src="entities.js"></script>
<script type="text/javascript" src="main.js"></script>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion examples/dirtyRect/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var jsApp =


// init the video
if (!me.video.init('jsapp', 1024, 768, true, 'auto', false))
if (!me.video.init('jsapp', 1024, 768, true, 'auto'))
{
alert("Sorry but your browser does not support html 5 canvas.");
return;
Expand Down
File renamed without changes.
31 changes: 16 additions & 15 deletions examples/platformer/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ var PlayerEntity = me.ObjectEntity.extend({
me.input.bindKey(me.input.KEY.DOWN, "down");

// walking animatin
this.addAnimation ("walk", [0,2,1]);
this.renderable.addAnimation ("walk", [0,2,1]);

// set default one
this.setCurrentAnimation("walk");
this.renderable.setCurrentAnimation("walk");
},

/* -----
Expand Down Expand Up @@ -112,7 +112,7 @@ var PlayerEntity = me.ObjectEntity.extend({
}

// check if we moved
if (this.vel.x!=0 || this.vel.y!=0 || this.isFlickering()) {
if (this.vel.x!=0 || this.vel.y!=0 || this.renderable.isFlickering()) {
this.parent();
return true;
}
Expand All @@ -125,9 +125,9 @@ var PlayerEntity = me.ObjectEntity.extend({
* ouch
*/
hurt : function () {
if (!this.flickering)
if (!this.renderable.flickering)
{
this.flicker(45);
this.renderable.flicker(45);
// flash the screen
me.game.viewport.fadeIn("#FFFFFF", 75);
me.audio.play("die", false);
Expand All @@ -151,15 +151,15 @@ var CoinEntity = me.CollectableEntity.extend({
this.parent(x, y , settings);

// animation speed
this.animationspeed = 8;
this.renderable.animationspeed = 8;

// bounding box
//this.updateColRect(8,16,16,16);

// walking animatin
this.addAnimation("spin", [0,1,2,3]);
this.renderable.addAnimation("spin", [0,1,2,3]);

this.setCurrentAnimation("spin");
this.renderable.setCurrentAnimation("spin");

},

Expand Down Expand Up @@ -210,16 +210,16 @@ var PathEnemyEntity = me.ObjectEntity.extend({

// custom animation speed ?
if (settings.animationspeed) {
this,animationspeed = settings.animationspeed;
this.renderable.animationspeed = settings.animationspeed;
}

// walking animatin
this.addAnimation ("walk", [0,1]);
this.renderable.addAnimation ("walk", [0,1]);
// dead animatin
this.addAnimation ("dead", [2]);
this.renderable.addAnimation ("dead", [2]);

// set default one
this.setCurrentAnimation("walk");
this.renderable.setCurrentAnimation("walk");
},


Expand Down Expand Up @@ -252,7 +252,7 @@ var PathEnemyEntity = me.ObjectEntity.extend({
// call the parent function
this.parent();
// return true if we moved of if flickering
return (this.vel.x != 0 || this.vel.y != 0 || this.isFlickering());
return (this.vel.x != 0 || this.vel.y != 0 || this.renderable.isFlickering());
},

/**
Expand All @@ -267,9 +267,10 @@ var PathEnemyEntity = me.ObjectEntity.extend({
// and not collidable anymore
this.collidable = false;
// set dead animation
this.setCurrentAnimation("dead");
this.renderable.setCurrentAnimation("dead");
// make it flicker and call destroy once timer finished
this.flicker(45, function(){me.game.remove(this)});
var self = this;
this.renderable.flicker(45, function(){me.game.remove(self)});
// dead sfx
me.audio.play("enemykill", false);
// give some score
Expand Down
2 changes: 1 addition & 1 deletion examples/whack-a-mole/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ var MoleEntity = me.AnimationSheet.extend(
/**
* a mole manager (to manage movement, etc..)
*/
var MoleManager = me.InvisibleEntity.extend(
var MoleManager = me.ObjectEntity.extend(
{
moles : [],

Expand Down
Loading