Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs

ct.js

Create cool 2D games with a free game editor! · By Cosmo Myzrail Gorynych

How to make a player character just like in 'Disposable Magic'

A topic by white_dreams47 created 81 days ago Views: 82 Replies: 2
Viewing posts 1 to 2
(1 edit)

By player character, I mean the part where the "Character" is able to point its wand in the direction that the mouse is pointing at then release an attack from that. Will I need to use skeletal parts for this?

Thank you very much in advance. I'm a beginner at programming and I really love this game and the engine.

Disposable Magic can be found here.

Developer

Hey,

It depends on your graphics and animation style whether or not you need skeletal animation, but disposable magic doesn't use such. It has a separate set of sprites with staffs and hands drawn on them.

For v1, you will need to create a simple sprite and attach it to your character:

this.wand = new PIXI.Sprite(ct.res.getTexture("MagicWand", 0)); // here we create a Sprite with a specified texture
this.addChild(this.wand); // here we attach it to our copy
this.wand.y = -20; //use this to align it properly
// Then, to actually rotate your wand:
var degrees = ct.u.pdn(this.x, this.y, ct.mouse.x, ct.mouse.y);
this.wand.rotation = degrees * Math.PI / -180; // PIXI uses radians when ct.js uses degrees, so here is how to convert one into another as well

Edit texture's anchor in ct.js "Textures" tab so it aligns properly while rotating. To spawn projectiles at the tip of your wand, you will need a bit of trigonometry. ct.u.ldx and ct.u.ldy will project a given length to a given direction, so you will use something like that:

var fireball = ct.types.copy('Fireball', this.x + ct.u.ldx(64, degree), this.y + ct.u.ldy(64, degree));

Sweet. I had it working. Thanks for the code, Sire!