Copy link to clipboard
Copied
I'm making a game in AS3 (point & click). I would like to do it for PC and for tablets. But, I've got a problem:
In my Pc version, when I go to the inventory and click on an item, the item will replace my cursor and I can dragg it where I went on the screen.
In my tactical version, when I click on the item, it will get stuck on the left corner of the screen. I suppose that the problem is that is no cursor in a tactical version..
Do you know what do I have to change for the tactical version ? (for exemple, the item stay in the middle off the screen and I have to click where I want it to be, no draging.
Thank you for your help,
Here is my code for my "dragItem" function :
public function DraggedItem(stageRef:Stage, grabbedItem:Object){
this.stageRef = stageRef;
toolbar = Engine.toolbar;
usableItems = Engine.usableItems;
inv = Engine.inv;
puzzle = Engine.puzzle;
player = Engine.player;
linesData = Engine.linesData;
inv.draggingItem = true;
Mouse.hide();
itemRef = getDefinitionByName(grabbedItem.displayName.toLowerCase()+"Proper");
draggedItem = new itemRef;
stageRef.addChild(draggedItem);
draggedItem.displayName = grabbedItem.displayName;
if (grabbedItem.lookTag)
draggedItem.lookTag = grabbedItem.lookTag;
draggedItem.x = mouseX + x;
draggedItem.y = mouseY + y;
draggedItem.scaleX = itemScale;
draggedItem.scaleY = itemScale;
stageRef.addEventListener(MouseEvent.MOUSE_MOVE, dragItem, false, 0, true);
stageRef.addEventListener(Event.ENTER_FRAME, itemHitTest, false, 0, true);
draggedItem.addEventListener(MouseEvent.CLICK, itemClick, false, 0, true);
}
private function dragItem(e:MouseEvent):void{
draggedItem.x = mouseX + x;
draggedItem.y = mouseY + y;
}
what's mouseX when that code executes? ie, mouseX probably's not defined when that code executes.
Copy link to clipboard
Copied
You're right ! It works on the mobile !!!! THX !!!!
Copy link to clipboard
Copied
you're welcome.