Problems with Animated Tiles [SOLVED]

Justin

  • *
  • Posts: 4445
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

TylerMacLeod

  • Posts: 16
I have the import code in a custom import event and the other code in a custom code block under a Keyboard event

I get this

Events for 'Scene2': Unknown identifier : Data
   from scripts.SceneEvents_2
   line: 98
   columns: 12-16

« Last Edit: September 07, 2016, 11:36:42 am by TylerMacLeod »

Justin

  • *
  • Posts: 4445
And you got that error you posted? Can you hit ctrl+j and post the entire code preview?
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

TylerMacLeod

  • Posts: 16
Code: [Select]
package scripts;

import com.stencyl.graphics.G;
import com.stencyl.graphics.BitmapWrapper;

import com.stencyl.behavior.Script;
import com.stencyl.behavior.Script.*;
import com.stencyl.behavior.ActorScript;
import com.stencyl.behavior.SceneScript;
import com.stencyl.behavior.TimedTask;

import com.stencyl.models.Actor;
import com.stencyl.models.GameModel;
import com.stencyl.models.actor.Animation;
import com.stencyl.models.actor.ActorType;
import com.stencyl.models.actor.Collision;
import com.stencyl.models.actor.Group;
import com.stencyl.models.Scene;
import com.stencyl.models.Sound;
import com.stencyl.models.Region;
import com.stencyl.models.Font;
import com.stencyl.models.Joystick;

import com.stencyl.Engine;
import com.stencyl.Input;
import com.stencyl.Key;
import com.stencyl.utils.Utils;

import openfl.ui.Mouse;
import openfl.display.Graphics;
import openfl.display.BlendMode;
import openfl.display.BitmapData;
import openfl.display.Bitmap;
import openfl.events.Event;
import openfl.events.KeyboardEvent;
import openfl.events.TouchEvent;
import openfl.net.URLLoader;

import box2D.common.math.B2Vec2;
import box2D.dynamics.B2Body;
import box2D.dynamics.B2Fixture;
import box2D.dynamics.joints.B2Joint;
import box2D.collision.shapes.B2Shape;

import motion.Actuate;
import motion.easing.Back;
import motion.easing.Cubic;
import motion.easing.Elastic;
import motion.easing.Expo;
import motion.easing.Linear;
import motion.easing.Quad;
import motion.easing.Quart;
import motion.easing.Quint;
import motion.easing.Sine;

import com.stencyl.graphics.shaders.BasicShader;
import com.stencyl.graphics.shaders.GrayscaleShader;
import com.stencyl.graphics.shaders.SepiaShader;
import com.stencyl.graphics.shaders.InvertShader;
import com.stencyl.graphics.shaders.GrainShader;
import com.stencyl.graphics.shaders.ExternalShader;
import com.stencyl.graphics.shaders.InlineShader;
import com.stencyl.graphics.shaders.BlurShader;
import com.stencyl.graphics.shaders.SharpenShader;
import com.stencyl.graphics.shaders.ScanlineShader;
import com.stencyl.graphics.shaders.CSBShader;
import com.stencyl.graphics.shaders.HueShader;
import com.stencyl.graphics.shaders.TintShader;
import com.stencyl.graphics.shaders.BloomShader;


/* ======================== Custom Import ========================= */
import com.stencyl.models.scene.Tileset;
/* ================================================================ */



class SceneEvents_2 extends SceneScript
{


public function new(dummy:Int, dummy2:Engine)
{
super();

}

override public function init()
{

/* =========================== Keyboard =========================== */
addKeyStateListener("interact", function(pressed:Bool, released:Bool, list:Array<Dynamic>):Void
{
if(wrapper.enabled && pressed)
{
setTileAt(Std.int(2),Std.int(9),0,"" + "2",1,2);

var tile = (Data.get().resources.get(1) : Tileset).tiles[2];
tile.currFrame = 0;
tile.currTime = 0;
tile.updateSource = true;
}
});

/* ======================= After N seconds ======================== */
runLater(1000 * 0.01, function(timeTask:TimedTask):Void
{
if(wrapper.enabled)
{
engine.cameraFollow(getActor(1));
}
}, null);

/* ======================= After N seconds ======================== */
runLater(1000 * 3.7, function(timeTask:TimedTask):Void
{
if(wrapper.enabled)
{
setTileAt(Std.int(2),Std.int(9),0,"" + "2",1,0);
}
}, null);

}

override public function forwardMessage(msg:String)
{

}
}

« Last Edit: September 07, 2016, 11:38:57 am by Justin »

Justin

  • *
  • Posts: 4445
Oh, sorry, I totally missed the second error you posted. Add this to your imports.

Code: [Select]
import com.stencyl.Data;
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

TylerMacLeod

  • Posts: 16
If I am importing "com.stencly.models.scene.Tileset;" shouldnt the code be "var tile = (Data.get().scene.get(1) : Tileset).tiles[2];" rather than "var tile = (Data.get().resources.get(1) : Tileset).tiles[2];"

Justin

  • *
  • Posts: 4445
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

TylerMacLeod

  • Posts: 16
Well, I am getting this error now
Code: [Select]
Events for 'Scene2': Null<com.stencyl.models.Resource> should be com.stencyl.models.scene.Tileset
from scripts.SceneEvents_2
line: 99
columns: 11-50
Events for 'Scene2': com.stencyl.models.Resource should be com.stencyl.models.scene.Tileset
from scripts.SceneEvents_2
line: 99
columns: 11-50

Justin

  • *
  • Posts: 4445
Try this.

Code: [Select]
var tile = cast(Data.get().resources.get(1), Tileset).tiles[2];
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

TylerMacLeod

  • Posts: 16
Wonderful! It works perfectly.