Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: self is undefined' in this line: 'var nutcrackerButton = self.createAsset('nutcrackerButton', 'Nutcracker Build Button', 0.5, 0);' Line Number: 27
Code edit (1 edits merged)
Please save this source code
User prompt
i want a nutcracker build button in the build menu
Code edit (1 edits merged)
Please save this source code
User prompt
Set the x position of the building menu to 0
User prompt
I want a building menu at the top
User prompt
Add three y-levels. One at y=2532, one at 2232 and one at 2032. when a mouse is spawned, spawn it at a random y-level
User prompt
Spawn every 600 ticks seconds a mouse at x= 0- mouse.width. Mouses move every tick 2 steps to the right. Destroy them, when they reach x=2048+mouse.width
User prompt
There are no mouses, mouse traps and nutcrackers at the start
User prompt
Add a background asset
Initial prompt
Nutcrackers VS Mouses
var Nutcracker = Container.expand(function () {
var self = Container.call(this);
var nutcrackerGraphics = self.createAsset('nutcracker', 'Nutcracker Graphics', .5, .5);
self.move = function () {};
self.attack = function () {};
});
var MouseTrap = Container.expand(function () {
var self = Container.call(this);
var mousetrapGraphics = self.createAsset('mousetrap', 'Mouse Trap Graphics', .5, .5);
self.activate = function () {};
});
var Mouse = Container.expand(function () {
var self = Container.call(this);
var mouseGraphics = self.createAsset('mouse', 'Mouse Graphics', .5, .5);
self.move = function () {};
self.attack = function () {};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var background = self.createAsset('background', 'Background Graphics', 0, 0);
self.addChildAt(background, 0);
var nutcrackers = [];
var mousetraps = [];
var mice = [];
var initGame = function () {
for (var i = 0; i < 5; i++) {
var nutcracker = new Nutcracker();
nutcracker.x = Math.random() * 2048;
nutcracker.y = Math.random() * 2732;
nutcrackers.push(nutcracker);
self.addChild(nutcracker);
}
for (var i = 0; i < 5; i++) {
var mousetrap = new MouseTrap();
mousetrap.x = Math.random() * 2048;
mousetrap.y = Math.random() * 2732;
mousetraps.push(mousetrap);
self.addChild(mousetrap);
}
for (var i = 0; i < 10; i++) {
var mouse = new Mouse();
mouse.x = Math.random() * 2048;
mouse.y = Math.random() * 2732;
mice.push(mouse);
self.addChild(mouse);
}
};
LK.on('tick', function () {
for (var i = 0; i < nutcrackers.length; i++) {
nutcrackers[i].move();
nutcrackers[i].attack();
}
for (var i = 0; i < mousetraps.length; i++) {
mousetraps[i].activate();
}
for (var i = 0; i < mice.length; i++) {
mice[i].move();
mice[i].attack();
}
});
initGame();
});
===================================================================
--- original.js
+++ change.js
@@ -16,8 +16,10 @@
self.attack = function () {};
});
var Game = Container.expand(function () {
var self = Container.call(this);
+ var background = self.createAsset('background', 'Background Graphics', 0, 0);
+ self.addChildAt(background, 0);
var nutcrackers = [];
var mousetraps = [];
var mice = [];
var initGame = function () {
Nut cracker, side view Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Mouse trap, side view, cartoon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a rolling nut, cartoon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a round giant snowball, cartoon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white background