File tree Expand file tree Collapse file tree 2 files changed +55
-2
lines changed
src/com/javagamemaker/javagameengine/components Expand file tree Collapse file tree 2 files changed +55
-2
lines changed Original file line number Diff line number Diff line change 1- package com .javagamemaker .javagameengine .components ;public class Tile {
1+ package com .javagamemaker .javagameengine .components ;
2+
3+ import com .javagamemaker .javagameengine .JavaGameEngine ;
4+ import com .javagamemaker .javagameengine .msc .Vector2 ;
5+
6+ import java .util .ArrayList ;
7+
8+ public class Tile extends GameObject {
9+ @ Override
10+ public void translate (Vector2 towards ) {
11+ int width = 1 ;
12+ try {
13+ width = ((TileMap )JavaGameEngine .getSelectedScene ()).tileWidth ;
14+ }catch (Exception e ){}
15+ towards = towards .multiply (width );
16+ super .translate (towards );
17+ }
18+
19+ @ Override
20+ public void setPosition (Vector2 position ) {
21+ //this.lastPosition = this.position;
22+ int width = 1 ;
23+ try {
24+ width = ((TileMap )JavaGameEngine .getSelectedScene ()).tileWidth ;
25+ }catch (Exception e ){}
26+
27+ if (getParent ()!=null ){
28+ this .position = position .add (parentOffset .multiply (width *2 )).add (rotOffset );
29+
30+ }else {
31+ prevPosition = this .position ;
32+ this .position = position ;
33+ }
34+ for (Component c : getChildren ()){
35+ c .setPosition (position );
36+ }
37+
38+ updateVertices ();
39+
40+ }
241}
Original file line number Diff line number Diff line change 1- package com .javagamemaker .javagameengine .components ;public class TileMap {
1+ package com .javagamemaker .javagameengine .components ;
2+
3+ import com .javagamemaker .javagameengine .Scene ;
4+ import com .javagamemaker .javagameengine .msc .Vector2 ;
5+
6+ public class TileMap extends Scene {
7+
8+ public int tileWidth =16 ;
9+
10+ @ Override
11+ public void add (Component component ) {
12+ component .setScale (new Vector2 (tileWidth ,tileWidth ));
13+ component .setPosition (component .getPosition ().multiply (tileWidth ));
14+ super .add (component );
15+ }
216}
You can’t perform that action at this time.
0 commit comments