Page 437 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 437
enumerable: true,
configurable: true
});
Position.prototype.toString = function () {
return "{x: " + this.x + ", y: " + this.y + "}";
};
return Position;
})();
ShellGame.Position = Position;
})(ShellGame || (ShellGame = {}));
Shellgame - Ball.js(공 제어 소스)
var ShellGame;
(function (ShellGame) {
var Ball = (function () {
function Ball(imageUrl, game, position) {
this.constants = new ShellGame.Constants(); //constants객체를 상속받음
this.game = game; //전역객체 game을 변수 this.game에 넣음
var image = new Image(); //image객체를 상속받음
image.src = imageUrl; //image의 url(src값)을 지정함
//객체를 상속받아서 해당 모듈을 사용하는 것이다. 각 모듈에 관한 정보들은 해당 모듈의 소스를 보고
해석하길 바란다.
var self = this; //this를 self에 넣는다.
image.onload = function () {
var width = image.width * self.constants.SCALE_FACTOR;
var height = image.height * self.constants.SCALE_FACTOR;
//constants모듈에 있는 SCALE_FACTOR(비율)값에 따라 이미지의 크기를 정한다.
var x = position.X - width / 2;
var y = position.Y - height / 2;
//공의 위치는 GameCanvas의 정 가운데일 것이다.
self.kineticImage = new Kinetic.Image({
x: x,
y: y,
image: image,
width: width,
- 430 -