« Next videoPrevious video »

Kha Tutorial Series Episode 080 - center position

we work with object all the time, but originally they start from the top left. we look to put our start point in the center of an object.

starting by creating a new project & a reusable Entity class. putting an x, y, width & height inside.
we then code out a ShapeObject that uses the Entity class. next, we make an ImageObject class which also uses the Entity class & make sure that the image affects the width & height.
our last class is FontObject also using the Entity class, using the fonts string & size to affect the width & height.

we then create a grid to show how the objects are rendered using the center point.

source code:
https://github.com/lewislepton/kha-tutorial-series

commit source:
https://github.com/Kode/Kha/tree/4efbe1e8dfaf4c1a21ef5f51bae9f4638dabee6c

SUPPORT ON PATREON FROM AS LITTLE AS $1:
https://patreon.com/lewislepton

intro & outro music is from this EP:
https://lewislepton.bandcamp.com/album/coat-noise-ep

like, share & subscribe to stay up to date.

https://lewislepton.com
https://patreon.com/lewislepton
https://twitter.com/lewislepton
https://facebook.com/lewislepton
https://lewislepton.bandcamp.com
https://soundcloud.com/lewislepton
https://github.com/lewislepton


Date: 2018-03-06

Other videos in 'Kha Tutorial Series'

Episode 081 - delete array entity

Episode 081 - delete array entity

Episode 080 - center position

Episode 080 - center position

Episode 079 - for loop draw

Episode 079 - for loop draw

Episode 078 - open URL

Episode 078 - open URL

Episode 077 - while loop circle

Episode 077 - while loop circle

Episode 076 - tank controls

Episode 076 - tank controls

Episode 074 - rotation revised

Episode 074 - rotation revised

Episode 073 - video capture

Episode 073 - video capture

Episode 072 - depth refine

Episode 072 - depth refine

Episode 071 - depth

Episode 071 - depth

Episode 070 - volume control

Episode 070 - volume control

Episode 069 - sine cosine

Episode 069 - sine cosine

Episode 068 - pivot point rotation

Episode 068 - pivot point rotation

Episode 067 - screen wrap

Episode 067 - screen wrap

Episode 066b - keycode

Episode 066b - keycode

Episode 066 - keycode

Episode 066 - keycode

Episode 065 - nape shapes drag

Episode 065 - nape shapes drag

Episode 064 - nape shapes impulse

Episode 064 - nape shapes impulse

Episode 063 - nape shapes collision data

Episode 063 - nape shapes collision data

Episode 062 - nape shapes conveyor belt

Episode 062 - nape shapes conveyor belt

Episode 061 - nape shapes material

Episode 061 - nape shapes material

Episode 060 - nape shapes images

Episode 060 - nape shapes images

Episode 058 - nape shapes collision fix

Episode 058 - nape shapes collision fix

Episode 059 - nape shapes rotation

Episode 059 - nape shapes rotation

Episode 057 - nape shapes

Episode 057 - nape shapes

Episode 056 - intro to nape

Episode 056 - intro to nape

Episode 055 - using extends

Episode 055 - using extends

Episode 054 - anti alias

Episode 054 - anti alias

Episode 053 - polygon

Episode 053 - polygon

Episode 052 - graphics one

Episode 052 - graphics one

Episode 051 - android touch

Episode 051 - android touch

Episode 050 - ios touch

Episode 050 - ios touch

Episode 049 - camera

Episode 049 - camera

Episode 048 - collision rectangle

Episode 048 - collision rectangle

Episode 047 - states button

Episode 047 - states button

Episode 046 - states

Episode 046 - states

Episode 045 - kha2d animation flip state

Episode 045 - kha2d animation flip state

Episode 044 - kha2d animation refine

Episode 044 - kha2d animation refine

Episode 043 - kha2d animation

Episode 043 - kha2d animation

Episode 042 - install kha2d

Episode 042 - install kha2d

Episode 040 - kha/kode studio changes

Episode 040 - kha/kode studio changes

Episode 041 - project sound

Episode 041 - project sound

Episode 039 - video

Episode 039 - video

Episode 038 - setup ffmpeg

Episode 038 - setup ffmpeg

Episode 036 - delta time

Episode 036 - delta time

Episode 037 - player movement delta

Episode 037 - player movement delta

Episode 035 - quit

Episode 035 - quit

Episode 034 - bouncingBall

Episode 034 - bouncingBall

Episode 033 - button

Episode 033 - button

Episode 031 - zui toggle

Episode 031 - zui toggle

Episode 032 - zui radio

Episode 032 - zui radio

Episode 030 - zui button

Episode 030 - zui button

Episode 029 - rotation

Episode 029 - rotation

Episode 027 - zui

Episode 027 - zui

Episode 028 - zui slider

Episode 028 - zui slider

Episode 026 - scissor

Episode 026 - scissor

Episode 025 - mouse position

Episode 025 - mouse position

Episode 024 - window options

Episode 024 - window options

Episode 023 - backbuffer

Episode 023 - backbuffer

Episode 022 - player gamepad

Episode 022 - player gamepad

Episode 021 - bounds

Episode 021 - bounds

Episode 020 - player movement

Episode 020 - player movement

Episode 019 - timer

Episode 019 - timer

Episode 018 - create entities using for loops

Episode 018 - create entities using for loops

Episode 017 - translate

Episode 017 - translate

Episode 016 - update

Episode 016 - update

Episode 015 - color

Episode 015 - color

Episode 014 - classes

Episode 014 - classes

Episode 013 - build

Episode 013 - build

Episode 012 - gamepad

Episode 012 - gamepad

Episode 011 - mouse

Episode 011 - mouse

Episode 010 - keyboard

Episode 010 - keyboard

Episode 009 - graphics

Episode 009 - graphics

Episode 008 - sound

Episode 008 - sound

Episode 007 - font & text

Episode 007 - font & text

Episode 006 - scaled images

Episode 006 - scaled images

Episode 005 - drawing shapes

Episode 005 - drawing shapes

Episode 004 - loading an image

Episode 004 - loading an image

Episode 003 - init kha project plus extras

Episode 003 - init kha project plus extras

Episode 002 - updating kha

Episode 002 - updating kha

Episode 001 - setting up everything

Episode 001 - setting up everything

Episode 000 - intro to haxe, kha & future plans

Episode 000 - intro to haxe, kha & future plans


Take the Haxe Survey!