User prompt
Frog is affected by gravitation
User prompt
Fix Bug: 'TypeError: frog.update is not a function' in this line: 'frog.update();' Line Number: 25
User prompt
Add main character, a frog.
User prompt
Fix Bug: 'TypeError: frog.update is not a function' in this line: 'frog.update();' Line Number: 25
Initial prompt
Jumping Frog
var Frog = Container.expand(function () {
var self = Container.call(this);
var frogGraphics = self.createAsset('frog', 'Frog character', .5, .5);
self.jump = function () {
self.y -= 100;
};
self.dodge = function () {
self.x += 100;
};
});
var LilyPad = Container.expand(function () {
var self = Container.call(this);
var lilyPadGraphics = self.createAsset('lilyPad', 'Lily pad', .5, .5);
self.move = function () {};
});
var Danger = Container.expand(function () {
var self = Container.call(this);
var dangerGraphics = self.createAsset('danger', 'Danger', .5, .5);
self.move = function () {};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var frog = self.addChild(new Frog());
var lilyPads = [];
var dangers = [];
frog.x = 2048 / 2;
frog.y = 2732 / 2;
LK.on('tick', function () {
frog.update();
for (var i = 0; i < lilyPads.length; i++) {
lilyPads[i].move();
if (lilyPads[i].x < -50) {
lilyPads[i].destroy();
lilyPads.splice(i, 1);
}
}
for (var i = 0; i < dangers.length; i++) {
dangers[i].move();
if (dangers[i].x < -50) {
dangers[i].destroy();
dangers.splice(i, 1);
}
}
});
stage.on('down', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
if (pos.y > frog.y) {
frog.jump();
} else {
frog.dodge();
}
});
});
===================================================================
--- original.js
+++ change.js
@@ -1,10 +1,13 @@
var Frog = Container.expand(function () {
var self = Container.call(this);
var frogGraphics = self.createAsset('frog', 'Frog character', .5, .5);
- self.jump = function () {};
- self.dodge = function () {};
- self.update = function () {};
+ self.jump = function () {
+ self.y -= 100;
+ };
+ self.dodge = function () {
+ self.x += 100;
+ };
});
var LilyPad = Container.expand(function () {
var self = Container.call(this);
var lilyPadGraphics = self.createAsset('lilyPad', 'Lily pad', .5, .5);
Cartoon lilypad Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cartoon tileable swamp background, dark Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cartoon. Green nuclear toxic fly Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon cute fat toad Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.